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

Support date type #20

Closed
wants to merge 14 commits into from
Closed

Support date type #20

wants to merge 14 commits into from

Conversation

ArsenyYankovsky
Copy link

No description provided.

@jeremydaly
Copy link
Owner

Thanks for your work on this, and sorry for the late reply. I'm not sure this makes sense for the library to handle the date type, since it's not a valid data type in the Data API. For now, I think it makes more sense to treat it as a regular string (like MySQL does) or as an integer (for timestamps) and then handle that in your code like we normally would with straight MySQL.

If I'm missing something here, let me know.

@ArsenyYankovsky
Copy link
Author

ArsenyYankovsky commented Nov 15, 2019

Well, it acts as a bridge between JS and the data API so I don't see a reason why it shouldn't be here. But the final decision is yours of course.

@jeremydaly
Copy link
Owner

I supposed it's possible (and probably straightforward) to support Date types in input parameters. We could convert Date objects into an ISO 8601 value and use StringValue (as your code suggests) to write to MySQL. I think we would want an option for auto-date conversion for queries, however. If true, we can inspect the field type (which we get from the columnMetaData object) and parse date/times appropriately. Thoughts?

@ArsenyYankovsky
Copy link
Author

Sounds like a good idea. Unfortunately, I have no idea when I will have time to work on it though.

@jeremydaly
Copy link
Owner

No worries. If it's important to the library, I can implement it. 👍

@juliedavila
Copy link

I'm hitting a need for this too

@juliedavila
Copy link

Looking at the latest docs

https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html

For some specific types, such as DECIMAL or TIME, a hint might be required to instruct the Data API that the String value should be passed to the database as a different type. You can do this by including values in typeHint in the SqlParameter data type. The possible values for typeHint are the following:

DECIMAL – The corresponding String parameter value is sent as an object of DECIMAL type to the database.

TIMESTAMP – The corresponding String parameter value is sent as an object of TIMESTAMP type to the database. The accepted format is YYYY-MM-DD HH:MM:SS[.FFF].

TIME – The corresponding String parameter value is sent as an object of TIME type to the database. The accepted format is HH:MM:SS[.FFF].

DATE – The corresponding String parameter value is sent as an object of DATE type to the database. The accepted format is YYYY-MM-DD.

Looks like we'd need to add that hint to the call

@cklam2
Copy link
Contributor

cklam2 commented Apr 14, 2020

Support implemented, see #28. Feedback welcome

@jeremydaly
Copy link
Owner

Closing this in favor of #28.

@jeremydaly jeremydaly closed this Jul 10, 2020
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

Successfully merging this pull request may close these issues.

None yet

5 participants