neo4j-contrib / neomodel

An Object Graph Mapper (OGM) for the Neo4j graph database.
https://neomodel.readthedocs.io
MIT License
936 stars 231 forks source link

Add wraps to wrapper defined in TransactionProxy #777

Closed giosava94 closed 4 months ago

giosava94 commented 7 months ago

Hi all,

first for all, thanks for your work and for keeping up to date this library!

I'm using neomodel in a FastAPI project to update a neo4j database. For each endpoint reading or writing to the database, I open a new DB transaction using the decorators write_transaction and read_transaction.

Since I'm using multiple wrappers from different libraries for each endpoint, I noticed that the TransactionProxy __init__ and __call__ functions were called when creating the endpoint, but the wrapper defined in __call__ and the __enter__ and __exit__ functions were not invoked.

This pull request adds the functools wraps function to that wrapper. Doing this I resolved the problem described before.

I executed the tests with pytest and they passed. I also noticed that the behavior with easier use cases does not change.

Let me know if this change introduces breaking changes or strange behavior (hopefully not).

Regards

sonarcloud[bot] commented 7 months ago

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

mariusconjeaud commented 4 months ago

Tested with the new async code (merge in rc/5.3.0) and it works just fine.

So I will merge this into a temp branch (rc/5.3.0-pre), so I can merge it back into the actual release candidate branch. This is because I otherwise need to just copy paste your code as the async and sync codebases are now split, and you won't be seen as a contributor anywhere :-)