skip polymorphic in pydantic v1

This commit is contained in:
John Lyu 2025-02-05 15:34:03 +08:00
parent 5d1bf5c2f3
commit d0d0288797

View File

@ -539,6 +539,7 @@ class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta):
config_kwargs = {
key: kwargs[key] for key in kwargs.keys() & allowed_config_kwargs
}
if IS_PYDANTIC_V2:
base_fields = {}
base_annotations = {}
for base in bases[::-1]:
@ -551,9 +552,8 @@ class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta):
base_annotations.update(dict_used["__annotations__"])
dict_used["__annotations__"] = base_annotations
base_fields.update(dict_used)
new_cls = super().__new__(
cls, name, bases, base_fields, **config_kwargs
)
dict_used = base_fields
new_cls = super().__new__(cls, name, bases, dict_used, **config_kwargs)
new_cls.__annotations__ = {
**relationship_annotations,
**pydantic_annotations,