]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Don't copy the types map from context to recursive dumpers
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 23 Jul 2021 16:45:11 +0000 (18:45 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 23 Jul 2021 21:50:05 +0000 (23:50 +0200)
It can be accessed from the object's transformer.

psycopg/psycopg/types/array.py
psycopg/psycopg/types/range.py

index 740c803c9bcdf6a530c7f250be5044a848e57ac6..1b82e76bac2ae1b5c46d83aee3b4d4ab458cf10f 100644 (file)
@@ -36,7 +36,6 @@ class BaseListDumper(RecursiveDumper):
     def __init__(self, cls: type, context: Optional[AdaptContext] = None):
         super().__init__(cls, context)
         self.sub_dumper: Optional[Dumper] = None
-        self._types = context.adapters.types if context else postgres.types
 
     def get_key(self, obj: List[Any], format: PyFormat) -> DumperKey:
         item = self._find_list_element(obj)
@@ -106,7 +105,7 @@ class BaseListDumper(RecursiveDumper):
         """
         oid = 0
         if base_oid:
-            info = self._types.get(base_oid)
+            info = self._tx.adapters.types.get(base_oid)
             if info:
                 oid = info.array_oid
 
index 561f5f466a11d0588f68dd8497dac60b0e23a99c..b343fd64460d48a17b8b6157d5fac5440f87defc 100644 (file)
@@ -256,7 +256,6 @@ class BaseRangeDumper(RecursiveDumper):
     def __init__(self, cls: type, context: Optional[AdaptContext] = None):
         super().__init__(cls, context)
         self.sub_dumper: Optional[Dumper] = None
-        self._types = context.adapters.types if context else postgres.types
         self._adapt_format = PyFormat.from_pq(self.format)
 
     def get_key(self, obj: Range[Any], format: PyFormat) -> DumperKey:
@@ -314,7 +313,7 @@ class BaseRangeDumper(RecursiveDumper):
 
         Raise InterfaceError if not found.
         """
-        info = self._types.get_range(sub_oid)
+        info = self._tx.adapters.types.get_range(sub_oid)
         return info.oid if info else INVALID_OID