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):
839839 instance = ModelSubclass (record )
840840 return instance
841841
842- def parse (self , s , curs ):
842+ def parse (self , s , curs , retry = False ):
843843 if s is None :
844844 return None
845845
846846 tokens = self .tokenize (s )
847847 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
849849 self .__dict__ .update (self ._from_db (self .name , curs ).__dict__ )
850850
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 )
853860
854861 return self .make (values )
855862
You can’t perform that action at this time.
0 commit comments