I am using node-mysql to update a MySQL database table from node.js. I want to update the timestamp column of a row with CURRENT_TIMESTAMP. However, no changes seem to be made by node.js using the following code:
Node.js Code
client.query('UPDATE listings SET job_checkout_timestamp = CURRENT_TIMESTAMP WHERE listing_id = 1515');
But works if I were to replace CURRENT_TIMESTAMP with a javascript time function, like new Date()
client.query('UPDATE listings SET job_checkout_timestamp = ? WHERE listing_id = 1515', [ new Date() ]);
However, if I were to execute the same SQL query directly into mysql (using Navicat), the row gets updated with the current timestamp!
Direct SQL Query
UPDATE listings SET job_checkout_timestamp = CURRENT_TIMESTAMP WHERE listing_id = 1515;
Did something go wrong somewhere?
select CURRENT_TIMESTAMP;?select CURRENT_TIMESTAMPworks both directly and through node.jsnow(), which is the same as current_timestamp. Hopefully node.js won't do any changes to function call.