Skip to content

decimal.Decimal breaks JsonModel.find() #654

@zidokobik

Description

@zidokobik

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 = 'example@example.com'
	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 ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions