Skip to content

feat: Typecast Javascript Date objects to ISOStrings #335

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/api.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ class Database
blobptr = allocate result, 'i8', ALLOC_NORMAL
sqlite3_result_blob(cx, blobptr,result.length, -1)
_free blobptr
else if result instanceof Date
sqlite3_result_text(cx, result.toISOString(), -1, -1)
Copy link
Member

@lovasoa lovasoa Jan 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is what you wanted ?
This change allows user-defined functions to return a Date. This is great, but wasn't #334 about adding Date support to prepared statement parameters ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the tips @lovasoa
Looks like I was too quick. I changed the build files and my test passed. Didn't realize there were two similar blocks of code.
Now that you have showed me the direction, let me take my time to fix the issues, add tests, add docs and polish the PR

else sqlite3_result_error(cx,"Wrong API use : tried to return a value of an unknown type (#{result}).",-1)
else sqlite3_result_null cx
return
Expand Down