Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of batch create_or_update raises Exception #747

Closed
mdurieux opened this issue Sep 19, 2023 · 2 comments
Closed

Use of batch create_or_update raises Exception #747

mdurieux opened this issue Sep 19, 2023 · 2 comments

Comments

@mdurieux
Copy link

mdurieux commented Sep 19, 2023

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\:"
@aanastasiou
Copy link
Collaborator

@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?

@mariusconjeaud
Copy link
Collaborator

Moving to #583

@mariusconjeaud mariusconjeaud closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants