Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion aredis_om/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions tests/test_hash_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion tests/test_json_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# type: ignore

import abc
import asyncio
import dataclasses
import datetime
import decimal
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down