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
When upgrading from sequelize 3, i noticed that some lookups does no longer produce valid sql. This is related to #9869, and has been tested against PR #9900, but is not affected by the pull request.
'use strict';constSequelize=require('sequelize');constOp=Sequelize.Op;letA,B,C;asyncfunctiontest(){constdb=newSequelize('test','user','user',{host: '127.0.0.1',dialect: 'postgresql',"quoteIdentifiers": true,"underscored": true});A=db.define('A',{str: Sequelize.STRING},{});B=db.define('B',{a_id : Sequelize.INTEGER,c_id : Sequelize.INTEGER},{});C=db.define('C',{str: Sequelize.STRING},{});B.belongsTo(A,{foreignKey: 'a_id'});A.hasMany(B,{foreignKey: 'a_id'});B.belongsTo(C,{foreignKey: 'c_id'});C.hasMany(B,{foreignKey: 'c_id'});awaitdb.sync({force: true});awaitpopulateDb();console.log('Find that does not reproduce the issue')constt1=awaitA.findAll({where: {str:'a'},include:[{model: B,required:true,include:{model:C,where:{str:'a'}}}]});console.log('Find that reproduces the issue, only limit differs')constt2=awaitA.findAll({where: {str:'a'},limit: 6,include:[{model: B,required:true,include:{model:C,where:{str:'a'}}}]});awaitdb.close();}asyncfunctionpopulateDb(){constc=awaitC.create({str:'a'});consta=awaitA.create({str:'a'});constb=awaitB.create({c_id:c.id,a_id:a.id});}asyncfunctionmain(){try{console.log('Bad sql');awaittest();}catch(err){console.error(err);process.exit(1);}}main();
What do you expect to happen?
I want the findAll to generate valid sql
What is actually happening?
Got an error - error: missing FROM-clause entry for table "Bs"
The steps to reproduce is different, and the pull request does not affect this one, so it seems like a separate issue from a users perspective, but I can add this as a comment to the other one if you desire
#9869 is regression related to sub queries which can be triggered by limit in various forms, including this one, PR is just an attempt not a fix all solution
What are you doing?
When upgrading from sequelize 3, i noticed that some lookups does no longer produce valid sql. This is related to #9869, and has been tested against PR #9900, but is not affected by the pull request.
What do you expect to happen?
I want the findAll to generate valid sql
What is actually happening?
Got an error - error: missing FROM-clause entry for table "Bs"
Output, either JSON or SQL
__Dialect:postgres
__Dialect version:(PostgreSQL) 9.6.5
__Database version:(PostgreSQL) 9.6.5
__Sequelize version:4.38.0
__Tested with latest release:4.38.0
Note : Your issue may be ignored OR closed by maintainers if it's not tested against latest version OR does not follow issue template.
The text was updated successfully, but these errors were encountered: