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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Automatically convert 'id' references in mongo queries to '_id' ObjectId equivalents

### Fixed

- Fixed 'AttributeError: 'FieldInfo' object has no attribute 'disable_on_mongo' when field is declared without `Field()` function

## [0.1.5] - 2025-02-18

### Added
Expand Down
1 change: 1 addition & 0 deletions examples/todos/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TodoList(BaseModel):
"""A list of Todos"""

name: str = Field(index=True, full_text_search=True)
description: str | None = None
todos: list["Todo"] = Relationship(back_populates="parent", default=[])


Expand Down
3 changes: 3 additions & 0 deletions examples/todos/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async def test_create_sql_todolist(
expected = {
"id": todolist_id,
"name": todolist["name"],
"description": None,
"todos": [
{
**raw,
Expand Down Expand Up @@ -66,6 +67,7 @@ async def test_create_redis_todolist(
expected = {
"id": todolist_id,
"name": todolist["name"],
"description": None,
"pk": todolist_id,
"todos": [
{
Expand Down Expand Up @@ -103,6 +105,7 @@ async def test_create_mongo_todolist(
expected = {
"id": todolist_id,
"name": todolist["name"],
"description": None,
"todos": [
{
**raw,
Expand Down
6 changes: 3 additions & 3 deletions nqlstore/_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,13 @@ def get_field_definitions(
fields = {}
for field_name, field in schema.model_fields.items(): # type: str, FieldInfo
class_field_definition = _get_class_field_definition(field)
if is_for_redis and class_field_definition.disable_on_redis:
if is_for_redis and getattr(class_field_definition, "disable_on_redis", False):
continue

if is_for_mongo and class_field_definition.disable_on_mongo:
if is_for_mongo and getattr(class_field_definition, "disable_on_mongo", False):
continue

if is_for_sql and class_field_definition.disable_on_sql:
if is_for_sql and getattr(class_field_definition, "disable_on_sql", False):
continue

field_type = field.annotation
Expand Down