pythonneo4jneo4j-ogmneomodel

Python Neomodel TypeError: Parameters of type UniqueIdProperty are not supported


When saving my object, I am getting this error, and I don't know why, what am I doing wrong? As far as I can see, I am using the UniqueIdProperty according to the documentation.

Traceback (most recent call last):
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 337, in fix_parameters
    dehydrated, = dehydrator.dehydrate([parameters])
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 406, in dehydrate
    return tuple(map(dehydrate_, values))
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 402, in dehydrate_
    return {key: dehydrate_(value) for key, value in obj.items()}
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 402, in <dictcomp>
    return {key: dehydrate_(value) for key, value in obj.items()}
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 404, in dehydrate_
    raise TypeError(obj)
TypeError: <neomodel.properties.UniqueIdProperty object at 0x00000236B1E4C400>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LARJAEG\PycharmProjects\openPrecision\tests\manual_tests\test_model.py", line 16, in test_model
    course.save()
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neomodel\hooks.py", line 14, in hooked
    val = fn(self)
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neomodel\core.py", line 641, in save
    self.cypher(query, params)
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neomodel\core.py", line 488, in cypher
    return db.cypher_query(query, params)
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neomodel\util.py", line 35, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neomodel\util.py", line 309, in cypher_query
    response = session.run(query, params)
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\work\simple.py", line 217, in run
    self._autoResult._run(
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\work\result.py", line 77, in _run
    parameters = DataDehydrator.fix_parameters(
  File "C:\Users\LARJAEG\AppData\Local\pypoetry\Cache\virtualenvs\open-precision-da2OwAle-py3.10\lib\site-packages\neo4j\data.py", line 340, in fix_parameters
    raise TypeError("Parameters of type {} are not supported".format(type(value).__name__))
TypeError: Parameters of type UniqueIdProperty are not supported

This is my model class:

from __future__ import annotations

from dataclasses import dataclass
from typing import TYPE_CHECKING

from neomodel import StructuredNode, UniqueIdProperty, Property, RelationshipTo, cardinality, StringProperty

from open_precision.core.model import DataModelBase

if TYPE_CHECKING:
    from open_precision.core.model.path import Path


@dataclass(kw_only=True)
class Course(StructuredNode, DataModelBase):
    id: str = UniqueIdProperty()
    name: str = StringProperty(required=True)
    description: str = StringProperty(required=False)

    CONTAINS: RelationshipTo = RelationshipTo('open_precision.core.model.path.Path',
                                              'CONTAINS',
                                              cardinality=cardinality.ZeroOrMore)

This is the code that raises the error, it initiates a course and saves it:

course = Course(name="test", description="bla")
course.save()

Thank you in advance.


Solution

  • Just as @Ferenc Pal described, renaming the attribute has solved the issue.