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

Inconsistent .pk behaviour #558

Open
kantholtz opened this issue Sep 6, 2023 · 0 comments
Open

Inconsistent .pk behaviour #558

kantholtz opened this issue Sep 6, 2023 · 0 comments

Comments

@kantholtz
Copy link

Hi, I've tripped over how the .pk property works for Models.

Consider this:

>>> from redis_om import HashModel, Field, Migrator
... 
... class A(HashModel):
...     x: int
... 
... class B(HashModel):
...     x: int = Field(primary_key=True)
... 
... Migrator().run()
... 
... a = A(x=3)
... b = B(x=3)
>>> a.pk
'01H9MZDZRHHDAQZY28F7ETGFHB'
>>> b.pk
<redis_om.model.model.ExpressionProxy object at 0x7f635ceb1d50>
  1. What is an ExpressionProxy object?
  2. Why is b.pk not 3?

In my opinion, using any HashModel or JsonModel should not require knowledge about whether their pk is auto-generated or explicitly declared.

I hope this was not described anywhere in the docs, but I did not find anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant