You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
query produces ambigious column reference when using attributes and include #4310
Great SSCCEThis issue has a great SSCCE/MCVE/reprex posted and therefore deserves extra attention! :)status: understoodFor issues. Applied when the issue is understood / reproducible.type: bugDEPRECATED: replace with the "bug" issue type
I realize this might just be a small, contrieved example, but there is no reason to use .col in this example. attributes: ['username'] will work fine, including aliasses.
.col is used in combination with other utilities, for example if you want to say sequelize.fn('upper', sequelize.col('soemthing') in order to tell sequelize that the arguemnt to the UPPER functiion is a column, not a string and should be escaped as such.
You could write .col('table.column') , although I realized this is not ideal, especially not when the same table can be included multiple times, under several alisses
Thanks for the feedback, and yes it also happens in s.fn().
Prefixing with the table name would work. Except I am generating the attributes from other data, so I need to write my own code to generate the same prefix, as sequelize does.
Is it guaranteed never to change? See #4315 it might have to change in order to fix this.
Although we use Sequelize in one of our projects, we've started another one on TypeORM. So maybe won't even have to wait. Will see and compare which one is better...
Great SSCCEThis issue has a great SSCCE/MCVE/reprex posted and therefore deserves extra attention! :)status: understoodFor issues. Applied when the issue is understood / reproducible.type: bugDEPRECATED: replace with the "bug" issue type
Activity
janmeier commentedon Aug 13, 2015
I realize this might just be a small, contrieved example, but there is no reason to use
.colin this example.attributes: ['username']will work fine, including aliasses..colis used in combination with other utilities, for example if you want to saysequelize.fn('upper', sequelize.col('soemthing')in order to tell sequelize that the arguemnt to theUPPERfunctiion is a column, not a string and should be escaped as such.You could write
.col('table.column'), although I realized this is not ideal, especially not when the same table can be included multiple times, under several alissesUser4martin commentedon Aug 13, 2015
Thanks for the feedback, and yes it also happens in s.fn().
Prefixing with the table name would work. Except I am generating the attributes from other data, so I need to write my own code to generate the same prefix, as sequelize does.
Is it guaranteed never to change? See #4315 it might have to change in order to fix this.
User4martin commentedon Jun 29, 2017
User4martin commentedon Aug 28, 2017
mrlubos commentedon Oct 1, 2017
jackson-sandland commentedon Dec 6, 2017
still an issue...bueller
when using the table.col notation I'm seeing:
"invalid reference to FROM-clause entry for table \"table\""9 remaining items
1valdis commentedon Jul 18, 2019
Yep.
1valdis commentedon Jul 18, 2019
Although we use Sequelize in one of our projects, we've started another one on TypeORM. So maybe won't even have to wait. Will see and compare which one is better...
je-poy commentedon Aug 13, 2019
Try this one attributes: [fn('trim', col('table1->table2->table3.col_name')), 'col_alias']
papb commentedon Aug 13, 2019
Indeed this is still an issue, here is a simplified SSCCE for reproduction:
SQL:
je-poy commentedon Aug 14, 2019
Try to add the table name on your Sequelize.col and use it on its singular form. Also try to add "->" if it is nested.
diegohideky commentedon Mar 31, 2020
I had the same problem, and I could fix this easily by enabling the flag
subQuerytotrueFantasyNeurotic commentedon May 28, 2020
@papb I suggest we can set the alias name when use the function of
find.e:bhavin-bhuva commentedon Apr 8, 2021
thank you bro worked for me
yogithesymbian commentedon Sep 17, 2022
not work
message
:
"Unknown column 'user.dm_personal->user.full_name' in 'field list'"
and subQuery , its not work ...
then