From b1ed8c36caf001438d12dbcf6e65c93a5bee6417 Mon Sep 17 00:00:00 2001 From: John Lyu Date: Wed, 5 Feb 2025 14:20:42 +0800 Subject: [PATCH] fix inherit order --- sqlmodel/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlmodel/main.py b/sqlmodel/main.py index b660a2f..a8d4936 100644 --- a/sqlmodel/main.py +++ b/sqlmodel/main.py @@ -548,9 +548,10 @@ class SQLModelMetaclass(ModelMetaclass, DeclarativeMeta): # use base_fields overwriting the ones from the class for inherit # if base is a sqlalchemy model, it's attributes will be an InstrumentedAttribute # thus pydantic will use the value of the attribute as the default value - dict_used["__annotations__"].update(base_annotations) + base_annotations.update(dict_used["__annotations__"]) + dict_used["__annotations__"] = base_annotations new_cls = super().__new__( - cls, name, bases, dict_used | base_fields, **config_kwargs + cls, name, bases, base_fields | dict_used, **config_kwargs ) new_cls.__annotations__ = { **relationship_annotations,