-
Notifications
You must be signed in to change notification settings - Fork 41
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
Using "now()" in an insert? #117
Comments
From what I can tell from a somewhat naive look through the code I'm not sure on how to specify that you would like to use the database/SQL NOW() on an insert, however (as you are probably aware), if you don't mind using the date-time according to your Swift program, then I believe you can pass a I will do some more experiments to see if there is a reasonable way to make this work with the current implementation. |
Yeah, this is pretty much the conclusion I had come to as well. The problem with just formatting a date on the Swift side is that theoretically different underlying RDBMSes could require different date formats. Not so much a worry with my project since I'm only using SQLite anyway, but it's the principle of the thing, ya know? |
It looks like the queryBuilder supports substitutions for NOW() so I don't see why we couldn't implement support for using NOW() outside filters. I am going to mark this as a potential enhancement and leave it as an item for future consideration. |
I'm basically trying to do something like
I also tried
Neither of these work as expected. The former builds a query like
INSERT INTO posts (id, date, title, body) VALUES ('1E417162-256C-40E0-8FDF-87A89A285B33', ScalarColumnExpression(alias: nil, function: SwiftKuery.ScalarColumnExpression.ScalarFunction.now), 'asdf', 'asdf')
- so the expression is being flatly converted to a string rather than having its.build(queryBuilder: QueryBuilder)
method called. The latter ultimately fails because it appears the parameter binding code is expecting simple variable types (String, Int, etc).Is there a correct way to do this? If so, what is it? If not, can I hack one together and make a PR?
The text was updated successfully, but these errors were encountered: