I'm trying to issue a bulk row insert using node-mysql, and normally this is not an issue, but I need to execute a mysql function on one of the columns.
Normally I would execute something like this and be fine:
INSERT INTO table1 (super_repo, reference, path, sub_repo, commit)
VALUES ?
ON DUPLICATE KEY
UPDATE sub_repo = VALUES(sub_repo), commit = VALUES(commit)
But, in this case, the 'commit' column is a BINARY field, so I need to execute the mysql UNHEX() on the commit string so it stores it properly in the database.
Passing the module this SQL throws a ER_PARSE_ERROR
INSERT INTO table1 (super_repo, reference, path, sub_repo, commit)
VALUES (?, ?, ?, ?, UNHEX(?))
ON DUPLICATE KEY
UPDATE sub_repo = VALUES(sub_repo), commit = VALUES(commit)
I'm guessing this doesn't work as it doesn't tell the MySql module that I am trying to insert multiple rows. Is there a way I can get this to work? Or alternatively, is there a node equivalent of doing the MySql UNHEX() so that I can use the first SQL query above?
via Nick
No comments:
Post a Comment