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:
6666finish_init : ContextVar [bool ] = ContextVar ("finish_init" , default = True )
6767
6868
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 :
7073 """By defalut, when init a model, pydantic will set the polymorphic_on
7174 value to field default value. But when inherit a model, the polymorphic_on
7275 should be set to polymorphic_identity value by default."""
7376 cls = type (self_instance )
7477 mapper = inspect (cls )
78+ ret = False
7579 if isinstance (mapper , Mapper ):
7680 polymorphic_on = mapper .polymorphic_on
7781 if polymorphic_on is not None :
@@ -87,6 +91,8 @@ def set_polymorphic_default_value(self_instance, values):
8791 polymorphic_property .key ,
8892 mapper .polymorphic_identity ,
8993 )
94+ ret = True
95+ return ret
9096
9197
9298@contextmanager
You can’t perform that action at this time.
0 commit comments