-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Description
What are you doing?
Nested where conditions are not related to their association.
const Sequelize = require('./')
const sequelize = new Sequelize({
dialect: 'sqlite',
file: ':memory:'
})
const Clientfile = sequelize.define('clientfile', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true
}
})
const Mission = sequelize.define('mission', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true
},
startDate: {
type: Sequelize.DATE
}
})
const Building = sequelize.define('building', {
id: {
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true
}
})
Clientfile.hasOne(Mission)
Clientfile.hasOne(Building)
const sync = async () => {
await Clientfile.sync()
await Mission.sync()
await Building.sync()
await Clientfile.findAll({
attributes: [],
include: [
{
association: 'mission',
attributes: ['id'],
where: {
startDate: {
[Sequelize.Op.gte]: new Date(),
[Sequelize.Op.lte]: new Date()
}
}
},
{
association: 'building',
attributes: ['id']
}
]
})
}
sync()What do you expect to happen?
The nested where condition is on mission association and should affect this association only
What is actually happening?
column building.startDate does not exist
The where condition of mission association seems to be applied to the building association.
Dialect: postgres
Sequelize version: 5.0.0-beta.14
Tested with latest release: Yes, 5.0.0-beta.15
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels