redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.13k stars 114 forks source link

Incorrect Query Mapping for Embedded Model #636

Open bilalzaib opened 3 months ago

bilalzaib commented 3 months ago

.find() method resulting incorrect query for the embedded model. The query should be (@player1_username:{username})| (@player2_username:{username}), but the query output is like (@player1_player2_username:{username})| (@player1_player2_username:{loadtest1}) that eventually returns a wrong output.

The following code can reproduce the issue

class Player(EmbeddedJsonModel):
    username: str = Field(index=True)

class Game(JsonModel):
    player1: Optional[Player]
    player2: Optional[Player]

q = Game.find((Game.player1.username=='username') | (Game.player2.username=='username'))
print(q.query)

Can someone guide me on how to resolve this issue?