File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,11 @@ def validate_access_primary_key_autotype(
240240 if name != "model_fields" :
241241 model_fields = object .__getattribute__ (self , "model_fields" )
242242 field = model_fields .get (name )
243- if field is not None and isinstance (field , FieldInfo ):
243+ if (
244+ field is not None
245+ and isinstance (field , FieldInfo )
246+ and hasattr (field , "primary_key" )
247+ ):
244248 if field .primary_key and field .annotation is int and value is None :
245249 raise ValueError (
246250 f"Primary key attribute '{ name } ' has not been set, please commit() it first."
@@ -547,7 +551,11 @@ def validate_access_primary_key_autotype(
547551 if name != "__fields__" :
548552 fields = object .__getattribute__ (self , "__fields__" )
549553 field = fields .get (name )
550- if field is not None and isinstance (field .field_info , FieldInfo ):
554+ if (
555+ field is not None
556+ and isinstance (field .field_info , FieldInfo )
557+ and hasattr (field .field_info , "primary_key" )
558+ ):
551559 if (
552560 field .field_info .primary_key
553561 and field .annotation is int
You can’t perform that action at this time.
0 commit comments