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 db specific node class registry #806

Closed mariusconjeaud closed 2 months ago

mariusconjeaud commented 3 months ago

Today, neomodel uses a single node class registry, to prevent collision of labels inside the database.

So this would not work :

class PatientOne(AsyncStructuredNode):
        __label__ = "Patient"
        name = StringProperty()

class PatientTwo(AsyncStructuredNode):
        __label__ = "Patient"
        identifier = StringProperty()

This PR adds a database-specific node class registry so that in the context of multiple databases, two different StructuredNode classes can map into the same label, but in different databases :

class PatientOne(AsyncStructuredNode):
        __label__ = "Patient"
        __target_databases__ = ["db_one"]
        name = StringProperty()

class PatientTwo(AsyncStructuredNode):
        __label__ = "Patient"
        __target_databases__ = ["db_two"]
        identifier = StringProperty()
codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 96.55172% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 91.47%. Comparing base (7c6662a) to head (53ff6fc).

Files Patch % Lines
neomodel/async_/core.py 96.00% 1 Missing :warning:
neomodel/sync_/core.py 96.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## rc/5.3.2 #806 +/- ## ========================================= Coverage 91.47% 91.47% ========================================= Files 34 34 Lines 4574 4600 +26 ========================================= + Hits 4184 4208 +24 - Misses 390 392 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sonarcloud[bot] commented 3 months ago

Quality Gate Failed Quality Gate failed

Failed conditions
18.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud