Skip to content

Commit 32ebd6f

Browse files
author
John Lyu
committed
avoid add ClassVar multiple times
1 parent 7d333fe commit 32ebd6f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sqlmodel/main.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,9 @@ def __new__(
553553
# create a dummy attribute to avoid inherit
554554
# pydantic will treat it as class variables, and will not become fields on model instances
555555
anno = base_annotations.get(k, Any)
556-
dummy_anno = ClassVar[anno]
557-
dict_used["__annotations__"][k] = dummy_anno
556+
if get_origin(anno) is not ClassVar:
557+
dummy_anno = ClassVar[anno]
558+
dict_used["__annotations__"][k] = dummy_anno
558559

559560
if hasattr(base, "__tablename__"):
560561
is_polymorphic = True

0 commit comments

Comments
 (0)