node-db-mysql icon indicating copy to clipboard operation
node-db-mysql copied to clipboard

wrong query building when changed orders of chains

Open tugrul opened this issue 13 years ago • 1 comments

var query = dbConn.query();
query.from('tablename');
query.where('`field3` = ?', [5]);
query.select(['field1','field2']);
console.log(query.sql());

Actual Result:

 FROM `tablename` WHERE field3 = 5SELECT `field1`,`field2`

Targetted Result:

SELECT `field1`,`field2` FROM `tablename` WHERE field3 = 5

tugrul avatar Jan 25 '12 13:01 tugrul

I'm seeing this same behavior for joins. If I call join() after having already called where() it wrongly places the join after the where clause. Based on this I presume the code is building the statement as it goes rather than queuing clauses to be built in the proper order later (when calling .sql or .execute)

talentedmrjones avatar Mar 05 '12 18:03 talentedmrjones