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
Regression in 5.18.x - "Unknown structure passed to order / group" when grouping by include (MySQL) #11421
Comments
I'm also seeing this when upgrading from Sequelize |
@geoffreak It seems nested array syntax in group by has been broken/removed. I think one workaround is to change your group from: group: [[FirstModel, 'pid']], to: group: ['first.pid'], |
I'll just hold off on the upgrade for now until this gets resolved. Good to know there's a workaround in case of a security patch. |
I believe I found the issue https://github.com/sequelize/sequelize/blob/master/lib/dialects/abstract/query-generator.js#L1367 The call to getAliasForGrouping is returning a null, so it's passing the "src" var to quote. If you are grouping by an array of arrays, the "src" var will only have the first item (model) in the array, not the full grouping array item. Replacing: return this.quote(this._getAliasForField(tableName, src, options) || src, model); with return this.quote(this._getAliasForField(tableName, src, options) || field, model); resolves the issue in a quick local test. Will try a PR and run tests to see if that causes any further issues |
@validkeys Nice, thanks, please try the PR :) |
Any news on this? Documentation states that this should work. |
Just encountered this in 5.22.3 with Postgres. Is this still conformed to be not fixed? Removing the nested array syntax addressed the issue. |
we updated yesterday to 5.22.4 and we are getting. |
after some investigation we figured out the error has nothing to do with Sequelize, rather with Serverless Offline ( which was recently updated and enabled hotmodulereloading. That caching functionality affects somehow Singletons and GlobalVariables and for some reason Sequelize initialization is affected, thus this error ( which was happening ONLY when invoking our endpoints --> sequelize via our react application from the browser on localhost - no issues in production, no errors when testing the endpoint individually via CURL) |
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Issue Description
Something broke with the 5.18.x releases that caused a regression in the group by behavior. I am now getting
Unknown structure passed to order / group
errors while trying to get some aggregates while grouping by an included model.What are you doing?
I have boiled down a working code example that demonstrates this issue.
What do you expect to happen?
In 5.17.2 and below, the following is output:
What is actually happening?
In 5.18.0 through 5.18.4 the following is output instead:
Additional context
N/A
Environment
5.18.0
through5.18.4
v8.16.0
macOS 10.14.6
n/a
Issue Template Checklist
How does this problem relate to dialects?
MySQL
, with connector librarymysql2
version1.5.2
and database version5.6
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: