redis-om-python
redis-om-python copied to clipboard
Inconsistent .pk behaviour
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>
- What is an
ExpressionProxy
object? - 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.