Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to use CURRENT_TIMESTAMP in update function? #19

Open
beenotung opened this issue Feb 4, 2022 · 0 comments
Open

Possible to use CURRENT_TIMESTAMP in update function? #19

beenotung opened this issue Feb 4, 2022 · 0 comments

Comments

@beenotung
Copy link
Contributor

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?

(This issue was previously submitted to the wrong repo at WiseLibs/better-sqlite3#760)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant