File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -839,17 +839,24 @@ def make(self, values):
839
839
instance = ModelSubclass (record )
840
840
return instance
841
841
842
- def parse (self , s , curs ):
842
+ def parse (self , s , curs , retry = False ):
843
843
if s is None :
844
844
return None
845
845
846
846
tokens = self .tokenize (s )
847
847
if len (tokens ) != len (self .atttypes ):
848
- # The type has changed, re-fetch it from the DB
848
+ # The number of columns has changed, re-fetch the type info
849
849
self .__dict__ .update (self ._from_db (self .name , curs ).__dict__ )
850
850
851
- values = [ curs .cast (oid , token )
852
- for oid , token in zip (self .atttypes , tokens ) ]
851
+ try :
852
+ values = [ curs .cast (oid , token )
853
+ for oid , token in zip (self .atttypes , tokens ) ]
854
+ except ValueError :
855
+ # The type of a column has changed, re-fetch it and retry once
856
+ if retry :
857
+ raise
858
+ self .__dict__ .update (self ._from_db (self .name , curs ).__dict__ )
859
+ return self .parse (s , curs , True )
853
860
854
861
return self .make (values )
855
862
You can’t perform that action at this time.
0 commit comments