Repository navigation
Open
Labels
dialect: mariadbFor issues and PRs. Things that involve MariaDB (and do not involve all dialects).status: understoodFor issues. Applied when the issue is understood / reproducible.
Description
What are you doing?
When querying with 2 levels of 'include' no results are returned. This only happens when using the 'mariadb' dialect. First join is a standard 1:N second join in N:N
When running the generated SQL on the DB directly the proper results are returned.
To Reproduce
Steps to reproduce the behavior:
- Define models
PSATicket
PSATicket.belongsTo(PSAContact, { foreignKey: 'contactId', targetKey: 'psaId' });PSAContact
attributes: {
psaId: { type: Sequelize.DataTypes.INTEGER, allowNull: false },
....
}
PSAContact.belongsToMany(User, { through: UserPSAContact, foreignKey: 'contactId' });UserPSAContact
attributes: {
userId: { type: Sequelize.DataTypes.INTEGER, allowNull: false, references: { model: 'user', key: 'id' } },
contactId: { type: Sequelize.DataTypes.INTEGER, allowNull: false, references: { model: 'psacontact', key: 'id' }
}
}User
User.belongsToMany(PSAContact, { through: UserPSAContact, foreignKey: 'userId' });- Run the following
// code here
let tTest = await SQ.PSATicket.findAll({
include: [{
attributes: [],
model: SQ.PSAContact,
required: true,
include: [{
nested: true,
attributes: [],
model: SQ.User
}]
}]
})- See error
What do you expect to happen?
Return all tickets which have a contact and that contact has a user mapped to it.
What is actually happening?
Returning empty array
Environment
Dialect:
- mariadb
Dialect library version: 2.0.4
Database version: 10.3.12-MariaDB
Sequelize version: 5.8.5
Node Version: 10.15.1
OS: Windows 10
Tested with latest release: - No
- Yes, specify that version: 5.8.5
Metadata
Metadata
Assignees
Labels
dialect: mariadbFor issues and PRs. Things that involve MariaDB (and do not involve all dialects).status: understoodFor issues. Applied when the issue is understood / reproducible.
Type
Projects
- StatusShow more project fieldsNo status
Activity
knoxcard commentedon May 8, 2019
@rusher
github-actions commentedon Nov 11, 2021
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂