fix: add support for json data type#593
fix: add support for json data type#593vi3k6i5 merged 9 commits intogoogleapis:mainfrom vi3k6i5:json_support
Conversation
larkee
left a comment
There was a problem hiding this comment.
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 🦕