Is overriding node labels with __label__
considered safe?
#711
-
Hi, I wanted to name my Neomodel model classes with a trailing "Node", for instance But, from looking at the cls.__label__ = namespace.get("__label__", name) So it appears we can override the label of the node by setting this as a attribute on the class: class PersonNode(neomodel.StructuredNode):
__label__ = "Person" I tested it in the CLI and it seems to work. It seems similar to what you can do in SQLAlchemy to point to the name of the table: class User(Base):
__tablename__ = "user" So I am wondering, does anyone know if this considered part of the public API and safe to hook into, or a private implementation detail that it's risky to rely on? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@nquinn-ek I would not call it "best practice" ( Having said that, if you are extending a data model and you have such clashes, you could resolve them by modifying the Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Here for the same reason. Frustrated that label is inferred from class name. Had to resort to setting label at declaration (will not be touched after). Would have almost been nice to have a public class attribute. |
Beta Was this translation helpful? Give feedback.
@nquinn-ek I would not call it "best practice" (
__label__
is "private" anyway), as it would differentiate what you perceive as an entity name in your program VS the backend. The label of a given entity is very important for the proper serialisation / deserialisation of the entity with the backend as well as setting up any indices. Most of the times, you don't have to deal with setting it manually.Having said that, if you are extending a data model and you have such clashes, you could resolve them by modifying the
__label__
as a last resort. It would be risky if you run across situations where you have to re-set that label a few times, in which case you would have to cleanup any remnants …