-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Unknown column in field list #11275
Comments
I updated Sequelize to version 5.12.2 but the problem is persists. |
I didn't know sequelize supported this syntax |
Wow, good question. Never checked out the documentation regarding this topic. I found many examples on Stack Overflow and many of these were accepted. So I thought this is supported by Sequelize. For example, on https://stackoverflow.com/questions/37817808/counting-associated-entries-with-sequelize the number of associated entries is counted by referencing a column using this way... |
Interesting, can you see if you can make it work in a super simple example? Yours didn't work, but perhaps you can find another simpler example, without |
What do you mean without includes? The includes are the problem because it seems that Sequelize creates a buggy query... |
I mean, does the |
I did some test again and simplified everything a bit and yes, it works, but let's see... The following query works correctly:
This prints the following:
So everything is fine and works as expected. So this proves that the discussed syntax works. But when I remove raw: true from the query, I'm getting an empty object:
It doesn't throw any error or rejection, but it simply prints an empty object:
Edit:\ When I execute the query of test2 generated by Sequelize directly on the database, I get a valid result (the same as for test1). |
Understood! Now, I understood the problem, but your code snippets are not self-contained (i.e. I can't just copy-paste it and run them). Can you (or someone else) please provide a SSCCE (also known as MCVE/reprex)? This will help tackling the issue faster. |
How to load attributes from the associated model in sequelize.js : |
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. 🙂 |
I have still the issue, every time when I want to find the avg of the column in the included model
|
@ihtishamKhan it would help if you could provide additional information like:
|
Sequelize make it easy to query data, but I don't know why it not working normally, maybe I am missing something or what |
What are you doing?
I'm executing the following query using Sequlize:
What do you expect to happen?
The field 'currentSession.activeSince' should be inclued in the attributes of the appropriate Session.
What is actually happening?
But instead of this, I'm getting the following error:
I figured out that the problem is that sequelize creates a query and references the activeSince-field as follows:
But the correct field would be:
Environment
Dialect:
Dialect library version: 1.6.5 (mysql2)
Database version: 5.7.21
Sequelize version: 5.10.1
Node Version: 12.6.0
OS: Windows 10
The text was updated successfully, but these errors were encountered: