-
Notifications
You must be signed in to change notification settings - Fork 116
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
Using Field from a different class causes the validator to wrongly assume there are multiple primary keys #671
Comments
Interesting, can you share some code where you see this error? |
from functools import partial
from sqlmodel import Field
NullableField = partial(Field, default=None, nullable=True)
class SomeModel(HashModel):
somefield: str | None = NullableField() |
This isn't enough to reproduce the issue. Can you please provide a minimal reproduction of the issue. |
ok you need at least 2 fields of such type: from functools import partial
import sqlmodel
from redis_om import HashModel
NullableField = partial(sqlmodel.Field, default=None, nullable=True)
class SomeModel(HashModel):
somefield1: str | None = NullableField()
somefield2: str | None = NullableField()
SomeModel() |
There's a conflict between sqlmodel and redis_om, they both have an attribute
|
yes it is defined as: primary_key: Union[bool, UndefinedType] = Undefined but a check with |
the code in
RedisModel
validate_primary_key
wrongly assumes there are multiple primary keys:should really be:
because I'm getting
PydanticUndefined
sometimes instead of NoneThe text was updated successfully, but these errors were encountered: