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

neomodel_inspect_database RelationshipTo model as string #799

Open gastongutierrez opened 3 months ago

gastongutierrez commented 3 months ago

Expected Behavior (Mandatory)

The model parameter should be assigned an object, not a string.

belongs_to = RelationshipTo("Marketing", "BELONGS_TO", cardinality=OneOrMore, model=BelongsToRel)

Actual Behavior (Mandatory)

The current script generates a string for the model parameter.

belongs_to = RelationshipTo("Marketing", "BELONGS_TO", cardinality=OneOrMore, model="BelongsToRel")

How to Reproduce the Problem

$ neomodel_inspect_database -db bolt://neo4j_username:neo4j_password@localhost:7687 --write-to yourapp/models.py

Simple Example

Datasets and Statements

Screenshots (where it's possibile)

Specifications (Mandatory)

Currently used versions

Versions

mariusconjeaud commented 3 months ago

That is done on purpose, because the model that the RelationshipTo refers to is actually defined after the node itself. So if you pass an object, your class file will not like it and you would have to reorder, or turn into a string yourself anyway. So I though I should make it a string straight away.

But, if you think it makes more sense, I could make sure that relationship models are always defined before any nodes ; or I don't pass it a string and let users fix the model as they see fit ?