You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To extend on this, I did some testing like below ; I thought the inheritance might be the problem, but no, it is indeed the presence of a UniqueIdProperty() that you don't pass at creation time.
asyncdeftest_issue_788():
classBaseNodeModel(AsyncStructuredNode):
uid=UniqueIdProperty()
created_at=DateTimeProperty(True)
updated_at=DateTimeProperty(True)
base_prop=StringProperty()
classInheritedPerson(BaseNodeModel):
name=StringProperty(required=True)
base_tim= (awaitBaseNodeModel.get_or_create({"base_prop": "Tim"}))[0]
should_be_same_base_tim= (awaitBaseNodeModel.get_or_create({"base_prop": "Tim"}))[
0
]
# This will pass if uid is commented out, but fail otherwiseassertbase_tim.element_id==should_be_same_base_tim.element_idfirst_tim= (awaitInheritedPerson.get_or_create({"name": "Tim"}))[0]
should_be_same_tim= (awaitInheritedPerson.get_or_create({"name": "Tim"}))[0]
# This will pass if uid is commented out, but fail otherwiseassertfirst_tim.element_id==should_be_same_tim.element_id
Meanwhile, this test works fine ; the difference being that on get_or_create, we do pass the uid explicitly, so it looks like that is the key.
Source of the issue is that the generate MERGE query looks like this : 'UNWIND $merge_params as params\n MERGE (n:BaseNodeModel {uid: params.create.uid})\n ON CREATE SET n = params.create\n RETURN n'
The key for the MERGE is the list of required properties ; in my above test, that is the uid property, which is auto-generated by the neomodel => does not match any existing node in the database => create instead of get
Expected Behavior (Mandatory)
This function is expected to find matching nodes by a filter object.
In case no nodes were found, The function should create a node.
Actual Behavior (Mandatory)
The function creates a duplicated node, even if the matching object returns a node (by manual check)
Simple Example
Declarations
Example
Specifications (Mandatory)
Versions
neomodel==5.2.1
The text was updated successfully, but these errors were encountered: