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
Include Where Cause Wrong Query Generated Only In MSSQL Dialect #9008
_But the output was:
two order by was generate,and throw error from sqlserver
_Output: SELECT [ LoginLog ].[ id ] AS [ ID ], [ LoginLog ].[ userid ] AS [ UserID ],[ USER ].[ userid ] AS [ USER.UserID ], [ USER ].[ username ] AS [ USER.UserName ] FROM [ public_loginlog ] AS [ LoginLog ] INNER JOIN [ public_user ] AS [ USER ] ON [ LoginLog ].[ userid ] = [ USER ].[ userid ] AND ( [ USER ].[ username ] LIKE N '%Bob%' ) ORDER BY [ USER ].[ username ] ORDER BY [ LoginLog ].[ id ] OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;
i find this appear when:
1.only in mssql.postgresql and mysql work fine!
2.only when use pagination:limit and offset
3.only when where in include
maybe cause from mssql dialect query-generator.js#L837
some problem like this problem,and not solve by now #8804
i think my problem give an easiest example of reproduction,please help me!
changed the title [-]Include Where Cause Wrong Query Generated Only In MSSQL DIalect[/-][+]Include Where Cause Wrong Query Generated Only In MSSQL Dialect[/+]on Feb 7, 2018
Activity
[-]Include Where Cause Wrong Query Generated Only In MSSQL DIalect[/-][+]Include Where Cause Wrong Query Generated Only In MSSQL Dialect[/+]sushantdhiman commentedon Feb 9, 2018
Please provide a SSCCE ( What is SSCCE ?, How to create one in Sequelize ? )
balazsnemeth commentedon Mar 8, 2018
#6706
lerit commentedon Mar 9, 2018
this is the sscce code,but i found this has no mssql dialect command in package.json script section.
`'use strict';
/*
*/
const Sequelize = require('./index');
const sequelize = require('./test/support').createSequelizeInstance();
const LoginLog = sequelize.define('LoginLog', {
ID: {
field: 'id',
type: DataTypes.INTEGER(11),
primaryKey: true,
autoIncrement: true
},
UserID: {
field: 'userid',
type: DataTypes.UUID,
allowNull: false
}
});
const User = sequelize.define('User', {
UserID: {
field: 'userid',
type: DataTypes.UUID,
primaryKey: true
},
UserName: {
field: 'username',
type: DataTypes.STRING(50),
allowNull: false
}
});
LoginLog.belongsTo(User, {
foreignKey: 'UserID',
constraints: false
});
function problemQuery() {
return LoginLog.findAll({
where: {},
include: [{
model: User,
where: {
UserName: {
$like: '%Bob%'
}
}
}],
order: [
[User, 'UserName', 'DESC']
],
offset: 10,
limit: 10
});
}
sequelize.sync({
force: true
})
.then(() => problemQuery());`
lerit commentedon Mar 9, 2018
@sushantdhiman please reopen this issue and help me ,thanks!