-
Notifications
You must be signed in to change notification settings - Fork 197
[Feature Request] Allow custom dehydration functions (and maybe hydration functions?) #576
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
Comments
Thanks for the input. What's the advantage of this over a thin wrapper around the driver's functions to dehydrate the objects before passing them to the driver. Something along the lines of def custom_dehydration(obj):
if isinstance(obj, UUID):
return str(obj)
elif isinstance(obj, ObjectId):
return str(obj)
return obj
def tx_run(tx, query, **parameters):
parameters = {k: custom_dehydration(v) for k, v in parameters.items()}
tx.run(query, **parameters) |
A wrapper function would also have to handle deep objects so it would have to be recursive. It would basically be a smaller version of the driver's neo4j-python-driver/neo4j/data.py Line 355 in fbefd15
A wrapper feels unnecessary when the logic is already in the driver and it is easily scalable, also it would mean passing through all parameters twice instead of once in the driver. |
Thanks again for the input. We've put the idea up on our internal Trello wall for future work https://trello.com/c/NajZu4P0. We'll come back to this issue as soon as we've made a decision of either rejecting it or putting it on the road-map for a future release. |
With #881 including third party type serialization and not returning the same type in response, have you considered adding the following types?
I can make a seperate feature request if you'd like |
Thanks for the feedback! I considered |
Would love a way to pass custom dehydration functions through config when starting the driver, this would give more flexibility for passing different python data types as parameters without having to convert each case separately. We currently monkeypatched your DataDehydrator as a workaround, to support UUID's and ObjectId's:
Having this as a built-in feature would of course be preferable over monkeypatching.
I've also considered hydration functions but I see that this could affect performance, since the types are not known beforehand and every string property would have to be checked. Currently we convert returned ID's back to UUID's for each query separately.
The text was updated successfully, but these errors were encountered: