You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
better-sqlite3-helper provides a helper function db.update(table, data, where, whiteList). For the data parameter, we can pass in a key-value pairs to specify the column name and column value.
However, it treats the value as literal value, e.g. db.update('user', {updated_at:'CURRENT_TIMESTAMP'}, {id:1}) will set the updated_at column to be string literal 'CURRENT_TIMESTAMP', instead of setting the column to the current database timestamp.
Work around is to use prepared statement, however that will be much more verbose. In the current design, is there a way to express sql expression on the column value part?
better-sqlite3-helper provides a helper function
db.update(table, data, where, whiteList)
. For thedata
parameter, we can pass in a key-value pairs to specify the column name and column value.However, it treats the value as literal value, e.g.
db.update('user', {updated_at:'CURRENT_TIMESTAMP'}, {id:1})
will set theupdated_at
column to be string literal'CURRENT_TIMESTAMP'
, instead of setting the column to the current database timestamp.Work around is to use prepared statement, however that will be much more verbose. In the current design, is there a way to express sql expression on the column value part?
(This issue was previously submitted to the wrong repo at WiseLibs/better-sqlite3#760)
The text was updated successfully, but these errors were encountered: