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

where clause fails with primary key using ISO8601 Date #137

Closed
nevf opened this issue Apr 14, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@nevf
Copy link

commented Apr 14, 2019

Which version are you using?
@nano-sql/core@2.2.4

Describe the bug
When I use : model: { "id:string": {pk: true}, ...
and use: id = new Date().toISOString()
then:

nSQL( tableName ).query( 'select' ).where( ['id','=',lastId] ).exec()

where lastId is a IS0 Date String that exists in the table I get no results. Likewise if I use >= instead of =.

If instead I use: id = Date.now() everything works as expected.

Some rows from the table:

0 | "2019-04-13T23:51:28.553Z" | {id: "2019-04-13T23:51:28.553Z", dump: {…}, type: undefined} |  
1 | "2019-04-13T23:51:31.500Z" | {id: "2019-04-13T23:51:31.500Z", dump: {…}, type: undefined}

I haven't tried queries on other fields that use ISO8601 Date strings, so this may be a wider issue.

@ClickSimply

This comment has been minimized.

Copy link
Owner

commented Apr 15, 2019

ISO8601 strings were being converted to the Date objects in where statements regardless of the column the where statement was querying against.

I didn't think there would be a case where folks would want to use ISO 8601 dates but not have them parsed.

In any case, 2.2.5 has just been released and changes the behavior of date rows to be more intuitive, let me know if it doesn't fix your issue.

@nevf

This comment has been minimized.

Copy link
Author

commented Apr 15, 2019

@ClickSimply Many thanks for the quick fix. All good now. It is always challenging to double guess what our users will do. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.