Manage tags view is not working with a table prefix

Describe the problem/error/question

The “Manage tags” view is not working, this is due to a failure in the “/tags” GET api, the reason is that we have a tablePrefix=‘n8n_’ and the query typeorm is generating is incorrect.

The problem is located on TagsController class (tags.controller.ts)

	// Retrieves all tags, with or without usage count
	@Get('/')
	async getAll(req: TagsRequest.GetAll): Promise<TagEntity[] | ITagWithCountDb[]> {
		const { withUsageCount } = req.query;
		if (withUsageCount === 'true') {
			return this.tagsRepository
				.find({
					select: ['id', 'name', 'createdAt', 'updatedAt'],
					relations: ['workflowMappings'],
				})
				.then((tags) =>
					tags.map(({ workflowMappings, ...rest }) => ({
						...rest,
						usageCount: workflowMappings.length,
					})),
				);
		}

		return this.tagsRepository.find({ select: ['id', 'name', 'createdAt', 'updatedAt'] });
	}

The sql generated by typeorm is the following:

SELECT n8n_tag_entity.id AS `id`, n8n_tag_entity.name AS `name`, 
		n8n_tag_entity.createdAt AS `createdAt`, n8n_tag_entity.updatedAt AS `updatedAt`, 
        COUNT(n8n_workflows_tags.workflowId) AS `usageCount` 
FROM `n8n_tag_entity` `tag_entity` 
	LEFT JOIN `n8n_workflows_tags` `workflows_tags` ON n8n_workflows_tags.tagId = `tag_entity`.`id` 
GROUP BY n8n_tag_entity.id;

Here we can see that the alias of the table is tag_entity but it’s trying to select it asn8n_tag_entity.id AS id``

What is the error message (if any)?

query: SELECT n8n_tag_entity.id AS `id`, n8n_tag_entity.name AS `name`, n8n_tag_entity.createdAt AS `createdAt`, n8n_tag_entity.updatedAt AS `updatedAt`, COUNT(n8n_workflows_tags.workflowId) AS `usageCount` FROM `n8n_tag_entity` `tag_entity` LEFT JOIN `n8n_workflows_tags` `workflows_tags` ON n8n_workflows_tags.tagId = `tag_entity`.`id` GROUP BY n8n_tag_entity.id
query failed: SELECT n8n_tag_entity.id AS `id`, n8n_tag_entity.name AS `name`, n8n_tag_entity.createdAt AS `createdAt`, n8n_tag_entity.updatedAt AS `updatedAt`, COUNT(n8n_workflows_tags.workflowId) AS `usageCount` FROM `n8n_tag_entity` `tag_entity` LEFT JOIN `n8n_workflows_tags` `workflows_tags` ON n8n_workflows_tags.tagId = `tag_entity`.`id` GROUP BY n8n_tag_entity.id
error: Error: Unknown column 'n8n_tag_entity.id' in 'field list

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

DB_TYPE: ‘mysqldb’
DB_TABLE_PREFIX: ‘n8n_’
DB_LOGGING_ENABLED: ‘true’
DB_LOGGING_OPTIONS: ‘all’

  • OS: [e.g. Ubuntu Linux 22.04]
  • n8n Version 0.222.3
  • Node.js Version 16
  • Database system mysql
  • Operation mode: own

Referencing also the in parallel opened GitHub issue:

Please, in the future just open it in one place. Posting it twice just costs us unnecessary work. Thanks!

For other users with the same problem. That issue got already fixed. Please update to 0.224.1.

Got it, thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.