hi, i use Sequelize.col in where like this:
Info.findOne(
include: [
{
model: Version,
where: {
versionId: Sequelize.col('Info.current_version')
}
}
]
);
Info.hasMany(Version, {
foreignKey: 'activity_id'
});
Version.belongsTo(Info, {
foreignKey: 'activity_id'
});
but, the sql is:
select
...
from
`info` AS `Info`
LEFT OUTER JOIN `version` AS `Versions`
ON `Info`.`activity_id` = `Versions`.`activity_id`
AND `info`.`current_version`
the sql i think should be:
select
...
from
`info` AS `Info`
LEFT OUTER JOIN `version` AS `Versions`
ON `Info`.`activity_id` = `Versions`.`activity_id`
AND `version`.`version_id` = `info`.`current_version`
So, what problem with this? How I can fix this? Thx~~
Yep, thats a bug
In the meantime, you can do sequelize.where(Sequelize.col('versionId'), Sequelize.col('Info.current_version'))
Use {$col: 'Info.current_version}
@mickhansen I spent hours searching for this event it was right in front of my eyes. Shouldn't this be documented well?
Most helpful comment
@mickhansen I spent hours searching for this event it was right in front of my eyes. Shouldn't this be documented well?