neo4j-contrib/neomodel

Use of batch create_or_update raises Exception

mdurieux opened this issue · 2 comments

Description

Use of batch create_or_update for a bunch of StructuredNode Objects

Expected behaviour

Neo4j populated

Actual behaviour

Exception occurs:
Traceback (most recent call last):
File "/Users/myUser/git-python/neo4j-lab01/src/myfolder/PopulateNeo4jFromHeliosDevGithub.py", line 49, in
Person.create_or_update(listPersons)
File "/opt/homebrew/lib/python3.11/site-packages/neomodel/core.py", line 509, in create_or_update
for specified, deflated in [
^
File "/opt/homebrew/lib/python3.11/site-packages/neomodel/core.py", line 510, in
(p, cls.deflate(p, skip_empty=True)) for p in props
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/neomodel/properties.py", line 92, in deflate
if properties.get(name) is not None:
^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'

Steps to reproduce

Datamodel :

from neomodel import StructuredNode, StringProperty, RelationshipTo, RelationshipFrom, StructuredRel, DateProperty

class Dog(StructuredNode):
name = StringProperty(required=True)
owner = RelationshipTo('Person', 'owner')

class Person(StructuredNode):
name = StringProperty(unique_index=True)
pets = RelationshipFrom('Dog', 'owner')

Code :

with db.transaction:

###### This code is working fine
people = Person.create_or_update(
    {'name': 'Tim', 'age': 83},
    {'name': 'Bob', 'age': 23},
    {'name': 'Jill', 'age': 34},
)
######

###### The code hereunder does raise Exception above

listPersons = []
listPersons.append(Person(name= 'Susan'))
listPersons.append(Person(name='Bob'))
Person.create_or_update(listPersons)

Additional info:

Output of the commands:

  • python --version
  • pip show connexion | grep "^Version\:"

@mdurieux Please see relevant documentation, create_or_update does not expect a list. Do you think that this answers your question or was there something I did not get?

Moving to #583