redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

decimal.Decimal breaks JsonModel.find()

Open zidokobik opened this issue 1 year ago • 0 comments

Consider the following code:

import asyncio
from decimal import Decimal
from aredis_om import JsonModel, Field, Migrator


class Book(JsonModel):
	author : str = Field(index=True)
	pages : Decimal = Field(index=True, default=Decimal('0'))


async def main():
	await Migrator().run()

	author = '[email protected]'
	book = Book(author=author)
	await book.save()

	query = await Book.find(Book.author == author).all()
	print(query)  # []

	
if __name__ == "__main__":
	with asyncio.Runner() as runner:
		runner.run(main())

query should not be empty.

Version: redis==4.6.0 redis-om==0.3.2 pydantic==2.8.2

Removing the Decimal field works as normal, so as using HashModel. Is this a bug ?

zidokobik avatar Sep 04 '24 02:09 zidokobik