node-db-mysql
node-db-mysql copied to clipboard
wrong query building when changed orders of chains
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
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)