Skip to content

The db:migrate command fails "Unknown structure passed to order/group: Literal { val: ' ASC' }." #1520

@mohamed-foly

Description

@mohamed-foly

I've encountered an issue after upgrading Sequelize from version 4.28.0 to 6.37.3. The db:migrate command fails with the following error message: "Unknown structure passed to order/group: Literal { val: ' ASC' }."

Here’s the exception log and stack trace:

Executing (default): SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'example_db';
Executing (default): SHOW FULL COLUMNS FROM `SequelizeMeta`;
Executing (default): SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE TYPE = 'BASE TABLE' AND TABLE_NAME = 'SequelizeMeta' AND TABLE_SCHEMA = 'example_db';
Executing (default): SHOW INDEX FROM `SequelizeMeta`;
Error: Unknown structure passed to order/group: Literal { val: ' ASC' }
    at MySQLQueryGenerator.quote (/node_modules/sequelize/lib/dialects/abstract/query-generator.js:690:13)
    at MySQLQueryGenerator.<anonymous> (/node_modules/sequelize/lib/dialects/abstract/query-generator.js:676:21)
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.quote (/node_modules/sequelize/lib/dialects/abstract/query-generator.js:675:27)
    at MySQLQueryGenerator.getQueryOrders (/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1586:34)
    at MySQLQueryGenerator.selectQuery (/node_modules/sequelize/lib/dialects/abstract/query-generator.js:1025:27)
    at MySQLQueryInterface.select (/node_modules/sequelize/lib/dialects/abstract/query-interface.js:407:59)
    at SequelizeMeta.findAll (/node_modules/sequelize/lib/model.js:1140:47)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Executing (default): SELECT `name` FROM `SequelizeMeta` AS `SequelizeMeta` ORDER BY `SequelizeMeta`.`name`undefined;

The issue seems to stem from the quote function in lib/dialects/abstract/query-generator.js. The expected result is that undefined should be resolved to ' ASC', but instead, it's being interpreted as Literal { val: ' ASC' }. This leads to an invalid SQL query, as shown in the final line of the log.

Any guidance on how to resolve this issue would be greatly appreciated.

umzug: ^2.3.0
sequelize: 6.37.3
sequelize-cli: 6.6.2
storage: SequelizeStorage
node: v16.20.2
dev setup: typescript

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions