-
Notifications
You must be signed in to change notification settings - Fork 90
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
fix: add support for json data type #593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you link to evidence that DB-API expects JSON to be passed in as a dict?
This code LGTM but I'm cautious about using dict unless there is precedent
If we pass a string from django, then type casting will be to "STRING", which causes this error. DB-api needs to know that json has to be passed, but that conversion happens based on instance type.
|
Hmm.. I see your point. Perhaps we should follow the route of
WDYT? |
This makes sense, but then users would be tied to using our data type in their code. The mapping would still have to be added and the conversion from
|
Apologies for bursting in without an invitation, but it should be mentioned we support such a params style: python-spanner/tests/unit/spanner_dbapi/test_parse_utils.py Lines 276 to 279 in f59d08b
Also there is a request to support Considering it, using |
Makes sense, will add a separate JSON type for the same. Update: I don't think the same rules apply because |
I guess it should live somewhere in https://github.com/googleapis/python-spanner/tree/main/google/cloud/spanner_v1/types, as a separate file (because in other files there are protos). Also there is a types.py file for DB API, but writing a class into this file looks like it's going to be used only by the DB API. |
@IlyaFaer : Thank you for the suggestion, added a new object called JsonObject and moved it to types. |
Ahh, unfortunately, that is a generated directory which means we shouldn't put handwritten code there as it will be overwritten/removed whenever the code is regenerated. I think the best option is to move
|
@larkee : Done, Thanks. |
Add support for json datatype, but adding mapping from dictionary to json for db insert.
Fixes #592 🦕