Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mohamed-foly opened this issue Sep 26, 2024 · 0 comments

Comments

@mohamed-foly
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant