node-querybuilder icon indicating copy to clipboard operation
node-querybuilder copied to clipboard

insert_ignore and dupe

Open aseprano opened this issue 6 years ago • 1 comments

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 ...')

aseprano avatar Nov 15 '19 17:11 aseprano

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

kylefarris avatar Nov 18 '19 18:11 kylefarris