I have the following setup (minimized for simplicity):
class Place(JsonModel, ABC):
id: str = Field(primary_key=True)
class Meta:
global_key_prefix = "places"
class Country(Place):
some_field: int = 1
class Meta:
model_key_prefix = "country"
class Province(Place):
another_field: bool = True
class Meta:
model_key_prefix = "province"
class City(Place):
yet_another_field: str = "bar"
class Meta:
model_key_prefix = "city"
And I want id fields (primary keys) to represent some hierarchy n order to be easily identifieable from the first glance.
For that I'd like to use the same : separator that is used for namespacing:
country = Country(id="ca")
province = Province(id="ca:qc")
city = City(id="ca:qc:montreal")
I have the following setup (minimized for simplicity):
And I want
id
fields (primary keys) to represent some hierarchy n order to be easily identifieable from the first glance. For that I'd like to use the same:
separator that is used for namespacing:So that the actual Redis keys look like that:
This setup works for most actions. For example, I can easily get the city like that:
But it does not work for
.all_pks()
.Expected behaviour:
Actual behaviour:
This behaviour is caused by this patch of code: https://github.com/redis/redis-om-python/blob/721f734aff770f56c54701629f578fe175d9ddda/aredis_om/model/model.py#L1530-L1535
Upon finding the key, it splits the key by
:
and takes the last part of it. Soplaces:city:ca:qc:montreal
becomesmontreal
.While it should just remove the
key_prefix
part. So thatplaces:city:ca:qc:montreal
becomesca:qc:montreal
.