File tree Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Expand file tree Collapse file tree 1 file changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -294,16 +294,19 @@ def sqlmodel_table_construct(
294
294
# Override polymorphic_on default value
295
295
mapper = inspect (cls )
296
296
polymorphic_on = mapper .polymorphic_on
297
- polymorphic_property = mapper .get_property_by_column (polymorphic_on )
298
- field_info = cls .model_fields .get (polymorphic_property .key )
299
- if field_info :
300
- v = values .get (polymorphic_property .key )
301
- # if model is inherited or polymorphic_on is not explicitly set
302
- # set the polymorphic_on by default
303
- if mapper .inherits or v is None :
304
- setattr (
305
- self_instance , polymorphic_property .key , mapper .polymorphic_identity
306
- )
297
+ if polymorphic_on :
298
+ polymorphic_property = mapper .get_property_by_column (polymorphic_on )
299
+ field_info = cls .model_fields .get (polymorphic_property .key )
300
+ if field_info :
301
+ v = values .get (polymorphic_property .key )
302
+ # if model is inherited or polymorphic_on is not explicitly set
303
+ # set the polymorphic_on by default
304
+ if mapper .inherits or v is None :
305
+ setattr (
306
+ self_instance ,
307
+ polymorphic_property .key ,
308
+ mapper .polymorphic_identity ,
309
+ )
307
310
return self_instance
308
311
309
312
def sqlmodel_validate (
You can’t perform that action at this time.
0 commit comments