kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

insert_ignore and dupe #59

Open aseprano opened 4 years ago

aseprano commented 4 years ago

Using the query builder following the documentation leads to an error: the argument list is not used as in the example (https://www.npmjs.com/package/node-querybuilder#insert_ignoretable-dataon_dupe-callback):

.insert_ignore(table, data[,on_dupe][, callback])

Looks like the third parameter is always expected to be the callback, not the on_dupe as above. Using the above signature will lead the query builder to totally ignore the on_dupe parameter.

That is: using the following code: conn.insert_ignore('mytable', {a: 10, b: 100}, 'ON DUPLICATE KEY UPDATE ...', (err, res) => {})

is wong and won't build the right query.

The following works fine:

conn.insert_ignore('mytable', {a: 10, b: 100}, (err, res) => {}, 'ON DUPLICATE KEY UPDATE ...')

kylefarris commented 4 years ago

Thanks for the bug report @aseprano. I'll look into it today if I get a chance.