fix polymorphic_on check
This commit is contained in:
parent
589237b80f
commit
4071b0fc64
@ -294,6 +294,7 @@ if IS_PYDANTIC_V2:
|
||||
# Override polymorphic_on default value
|
||||
mapper = inspect(cls)
|
||||
polymorphic_on = mapper.polymorphic_on
|
||||
if polymorphic_on:
|
||||
polymorphic_property = mapper.get_property_by_column(polymorphic_on)
|
||||
field_info = cls.model_fields.get(polymorphic_property.key)
|
||||
if field_info:
|
||||
@ -302,7 +303,9 @@ if IS_PYDANTIC_V2:
|
||||
# set the polymorphic_on by default
|
||||
if mapper.inherits or v is None:
|
||||
setattr(
|
||||
self_instance, polymorphic_property.key, mapper.polymorphic_identity
|
||||
self_instance,
|
||||
polymorphic_property.key,
|
||||
mapper.polymorphic_identity,
|
||||
)
|
||||
return self_instance
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user