Skip to content

Commit d13416e

Browse files
committed
Deal with Pydantic protected namespace conflicts
1 parent b25655a commit d13416e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

nannyml/io/db/entities.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from datetime import datetime
1212
from typing import List, Optional
1313

14+
from pydantic import ConfigDict
1415
from sqlmodel import Field, Relationship, SQLModel
1516

1617

@@ -42,6 +43,11 @@ class Run(SQLModel, table=True): # type: ignore[call-arg]
4243
Stored in the ``run`` table.
4344
"""
4445

46+
# Ignore clash of `model_id` field name with default protected namespace `model_`
47+
# See: https://github.com/pydantic/pydantic/discussions/7121
48+
# Better solution using `alias` is not possible due to SQLModel issue
49+
model_config = ConfigDict(protected_namespaces=())
50+
4551
#: Foreign key in all ``metric`` tables
4652
id: Optional[int] = Field(default=None, primary_key=True)
4753

@@ -61,6 +67,11 @@ class Metric(SQLModel):
6167
Base ``Metric`` definition.
6268
"""
6369

70+
# Ignore clash of `model_id` field name with default protected namespace `model_`
71+
# See: https://github.com/pydantic/pydantic/discussions/7121
72+
# Better solution using `alias` is not possible due to SQLModel issue
73+
model_config = ConfigDict(protected_namespaces=())
74+
6475
#: The technical identifier for this database row
6576
id: Optional[int] = Field(default=None, primary_key=True)
6677

0 commit comments

Comments
 (0)