diff --git a/aredis_om/model/model.py b/aredis_om/model/model.py index f95d4ce5..78eb5329 100644 --- a/aredis_om/model/model.py +++ b/aredis_om/model/model.py @@ -1984,7 +1984,9 @@ def schema_for_fields(cls): if issubclass(_type, str): redisearch_field = f"$.{name} AS {name} TAG SEPARATOR {SINGLE_VALUE_TAG_FIELD_SEPARATOR}" else: - redisearch_field = cls.schema_for_type(name, _type, field_info) + redisearch_field = cls.schema_for_type( + json_path, name, "", _type, field_info + ) schema_parts.append(redisearch_field) continue schema_parts.append( diff --git a/tests/test_hash_model.py b/tests/test_hash_model.py index 209c8a5e..de4bdb89 100644 --- a/tests/test_hash_model.py +++ b/tests/test_hash_model.py @@ -900,6 +900,7 @@ class ModelWithStringDefault(HashModel): assert res.test == "None" +@py_test_mark_asyncio async def test_update_validation(): class TestUpdate(HashModel): name: str diff --git a/tests/test_json_model.py b/tests/test_json_model.py index 267185a5..4125bf8b 100644 --- a/tests/test_json_model.py +++ b/tests/test_json_model.py @@ -1,6 +1,7 @@ # type: ignore import abc +import asyncio import dataclasses import datetime import decimal @@ -994,8 +995,8 @@ class ModelWithStringDefault(JsonModel): assert res.test == "None" +@py_test_mark_asyncio async def test_update_validation(): - class Embedded(EmbeddedJsonModel): price: float name: str = Field(index=True) @@ -1025,6 +1026,7 @@ class TestUpdatesClass(JsonModel): assert rematerialized.age == 42 +@py_test_mark_asyncio async def test_model_with_dict(): class EmbeddedJsonModelWithDict(EmbeddedJsonModel): dict: Dict @@ -1071,6 +1073,17 @@ class Example(JsonModel): assert res.name == ex.name +@py_test_mark_asyncio +async def test_int_pk(): + class ModelWithIntPk(JsonModel): + my_id: int = Field(index=True, primary_key=True) + + await Migrator().run() + await ModelWithIntPk(my_id=42).save() + + m = await ModelWithIntPk.find(ModelWithIntPk.my_id == 42).first() + assert m.my_id == 42 + @py_test_mark_asyncio async def test_pagination(): class Test(JsonModel):