I'm trying to use the MySQL function "now()" in an insert statement using the node-mysql module:
var insert = {
username: 'foo',
date_joined: 'now()',
};
connection.query('INSERT INTO users SET ?', [insert],function(err, result){ ... });
As I expected, this gives me an error, Error: ER_TRUNCATED_WRONG_VALUE: Incorrect datetime value: 'now()' for column 'date_joined', as it escaped the now() function to a string instead of letting MySQL parse it as the function I intended.
In practicality, my insert statement and query is much more complicated, and so I'd like to utilize the escaping query values shortcuts node-mysql offers rather than building out my query manually.
How can I tell node-mysql NOT to escape the now() function?
date_joined? Why do you use placeholders here if it's not a constant value but a function call?datetimetype. I don't need to use a placeholder for the function I guess, but that would make it much more readable.now()? If so - why not put it in a query as-is?