Skip to content

Commit

Permalink
Add underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
as51340 committed Sep 20, 2023
1 parent 762e29b commit 744b0f8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions gqlalchemy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def to_cypher(self) -> str:


class GraphObject(BaseModel):
subtypes: Dict = dict()
_subtypes_: Dict = dict()

class Config:
extra = Extra.allow
Expand All @@ -312,11 +312,11 @@ def __init_subclass__(cls, type=None, label=None, labels=None, index=None, db=No
when instantiating a subclass.
"""
if type is not None: # Relationship
cls.subtypes[type] = cls
cls._subtypes_[type] = cls
elif label is not None: # Node
cls.subtypes[label] = cls
cls._subtypes_[label] = cls
else:
cls.subtypes[cls.__name__] = cls
cls._subtypes_[cls.__name__] = cls

@classmethod
def __get_validators__(cls):
Expand All @@ -330,12 +330,12 @@ def _convert_to_real_type_(cls, data):
"""
sub = None
if "_type" in data: # Relationship
sub = cls.subtypes.get(data.get("_type"))
sub = cls._subtypes_.get(data.get("_type"))

if "_labels" in data: # Node
# Find class that has the most super classes
labels = data["_labels"]
classes = [cls.subtypes[label] for label in labels if label in cls.subtypes]
classes = [cls._subtypes_[label] for label in labels if label in cls._subtypes_]
counter = defaultdict(int)
for class1 in classes:
counter[class1] += sum(issubclass(class1, class2) for class2 in classes)
Expand Down

0 comments on commit 744b0f8

Please sign in to comment.