@@ -835,7 +835,7 @@ def parse(self, s, curs, retry=False):
835
835
tokens = self .tokenize (s )
836
836
if len (tokens ) != len (self .atttypes ):
837
837
# The number of columns has changed, re-fetch the type info
838
- self .__dict__ . update ( self . _from_db ( self . name , curs ). __dict__ )
838
+ self ._refetch_type_info ( curs )
839
839
840
840
try :
841
841
values = [ curs .cast (oid , token )
@@ -844,7 +844,7 @@ def parse(self, s, curs, retry=False):
844
844
# The type of a column has changed, re-fetch it and retry once
845
845
if retry :
846
846
raise
847
- self .__dict__ . update ( self . _from_db ( self . name , curs ). __dict__ )
847
+ self ._refetch_type_info ( curs )
848
848
return self .parse (s , curs , True )
849
849
850
850
return self .make (values )
@@ -864,6 +864,12 @@ def make(self, values):
864
864
instance = ModelSubclass (record )
865
865
return instance
866
866
867
+ def _refetch_type_info (self , curs ):
868
+ """Given a cursor, update the current object with a fresh type definition.
869
+ """
870
+ new_self = self ._from_db (self .name , curs )
871
+ self .__dict__ .update (new_self .__dict__ )
872
+
867
873
return DelegatingCaster
868
874
869
875
0 commit comments