File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -66,12 +66,16 @@ def _is_union_type(t: Any) -> bool:
66
66
finish_init : ContextVar [bool ] = ContextVar ("finish_init" , default = True )
67
67
68
68
69
- def set_polymorphic_default_value (self_instance , values ):
69
+ def set_polymorphic_default_value (
70
+ self_instance : _TSQLModel ,
71
+ values : Dict [str , Any ],
72
+ ) -> bool :
70
73
"""By defalut, when init a model, pydantic will set the polymorphic_on
71
74
value to field default value. But when inherit a model, the polymorphic_on
72
75
should be set to polymorphic_identity value by default."""
73
76
cls = type (self_instance )
74
77
mapper = inspect (cls )
78
+ ret = False
75
79
if isinstance (mapper , Mapper ):
76
80
polymorphic_on = mapper .polymorphic_on
77
81
if polymorphic_on is not None :
@@ -87,6 +91,8 @@ def set_polymorphic_default_value(self_instance, values):
87
91
polymorphic_property .key ,
88
92
mapper .polymorphic_identity ,
89
93
)
94
+ ret = True
95
+ return ret
90
96
91
97
92
98
@contextmanager
You can’t perform that action at this time.
0 commit comments