redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.06k stars 108 forks source link

aredis_om and pydantic-v2 @model_validator RecursionError #583

Closed brodyreiss1 closed 2 months ago

brodyreiss1 commented 6 months ago

When trying to add a pydantic v2 model validator to my aredis_om JsonModel, a RecursionError occurs. When testing both aredis_om and the validator separately, both work without error. When testing together a maximum depth search error occurs.

Here is example code that recreates this issue...

from aredis_om import JsonModel
from pydantic import model_validator

class Test(JsonModel):
    name: str

    @model_validator(mode='after')
    async def create_name(self):
        self.name = 'this is different'
        return self

    @classmethod
    async def create(cls, name):
        test = cls(name=name)
        await test.save()
slorello89 commented 3 months ago

I think this will probably be solved by #603