-
Notifications
You must be signed in to change notification settings - Fork 80
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
handling Date value #22
Comments
Yeap, it looks like a bug. But what behaviour will be correct? What should be returned from Date instance: .valueOf() or .toISOString()? As workaround you could call specific method in your code: var date = new Date();
var result = jsonSql.build({
table: 'users',
condition: {
insertdate: date.valueOf()
}
}); |
I think it should be neither of these. Database clients are written to handle Date instances. Here is an example for Postgres showing a Handling javascript Date is hairy and people who wrote database clients spent a lot of time making sure they'll be handled correctly. So json-sql should leave variable as-is and let these clients handle it. The result of
The only situation when json-sql should convert value is when However, in this case, the Date needs to be converted to a string in a format recognizable by the database. Here is a case showing that use of
|
@DmitryEfimenko solution looks good to me, @artzhookov ? |
@artzhookov if you point me in the right direction (where the changes need to happen), I can try submit a PR |
Before I'll able to give you an advice I need to look at the code. I think I'll have time today to find right place at the code and I'll answer after. |
Please, try [email protected], it should process Date values properly now |
Awesome work!
I think it has to do with this line |
I have a simple select statement with a condition having a column equaling to a Date instance. Please see the result. Does not seem like it's an expected behavior.
Of course, running this results in an error.
I tried to poke around in the code, but could not quite see where to handle this. Any suggestions/help are appreciated.
The text was updated successfully, but these errors were encountered: