From: Daniele Varrazzo Date: Fri, 7 Aug 2020 02:49:20 +0000 (+0100) Subject: Dropped Transformer.load() X-Git-Tag: 3.0.dev0~458^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a5a0b734abd0f6a7759869baf393180af347f3f;p=thirdparty%2Fpsycopg.git Dropped Transformer.load() --- diff --git a/psycopg3/psycopg3/proto.py b/psycopg3/psycopg3/proto.py index 84601a4f7..c54075c47 100644 --- a/psycopg3/psycopg3/proto.py +++ b/psycopg3/psycopg3/proto.py @@ -90,9 +90,6 @@ class Transformer(Protocol): ) -> Tuple[Any, ...]: ... - def load(self, data: bytes, oid: int, format: Format = Format.TEXT) -> Any: - ... - def get_load_function(self, oid: int, format: Format) -> LoadFunc: ... diff --git a/psycopg3/psycopg3/transform.py b/psycopg3/psycopg3/transform.py index c8ca92727..15cf937f6 100644 --- a/psycopg3/psycopg3/transform.py +++ b/psycopg3/psycopg3/transform.py @@ -187,13 +187,6 @@ class Transformer: for i, val in enumerate(record) ) - def load(self, data: bytes, oid: int, format: Format = Format.TEXT) -> Any: - if data is not None: - f = self.get_load_function(oid, format) - return f(data) - else: - return None - def get_load_function(self, oid: int, format: Format) -> LoadFunc: key = (oid, format) try: diff --git a/psycopg3_c/psycopg3_c/_psycopg3.pyi b/psycopg3_c/psycopg3_c/_psycopg3.pyi index 50bf51bc5..e63060408 100644 --- a/psycopg3_c/psycopg3_c/_psycopg3.pyi +++ b/psycopg3_c/psycopg3_c/_psycopg3.pyi @@ -39,9 +39,6 @@ class Transformer: def load_sequence( self, record: Sequence[Optional[bytes]] ) -> Tuple[Any, ...]: ... - def load( - self, data: bytes, oid: int, format: pq.Format = pq.Format.TEXT - ) -> Any: ... def get_load_function(self, oid: int, format: pq.Format) -> LoadFunc: ... def lookup_loader(self, oid: int, format: pq.Format) -> LoaderType: ... diff --git a/psycopg3_c/psycopg3_c/transform.pyx b/psycopg3_c/psycopg3_c/transform.pyx index bc6898bc0..460e7ac10 100644 --- a/psycopg3_c/psycopg3_c/transform.pyx +++ b/psycopg3_c/psycopg3_c/transform.pyx @@ -250,13 +250,6 @@ cdef class Transformer: return tuple(rv) - def load(self, data: bytes, oid: int, format: Format = Format.TEXT) -> Any: - if data is not None: - f = self.get_load_function(oid, format) - return f(data) - else: - return None - def get_load_function(self, oid: int, format: Format) -> "LoadFunc": key = (oid, format) try: diff --git a/tests/test_adapt.py b/tests/test_adapt.py index 5f01a97c4..9bb074553 100644 --- a/tests/test_adapt.py +++ b/tests/test_adapt.py @@ -48,8 +48,6 @@ def test_dump_cursor_ctx(conn): @pytest.mark.parametrize( "data, format, type, result", [ - (None, Format.TEXT, "text", None), - (None, Format.BINARY, "text", None), (b"1", Format.TEXT, "int4", 1), (b"hello", Format.TEXT, "text", "hello"), (b"hello", Format.BINARY, "text", "hello"), @@ -57,7 +55,7 @@ def test_dump_cursor_ctx(conn): ) def test_cast(data, format, type, result): t = Transformer() - rv = t.load(data, builtins[type].oid, format) + rv = t.get_loader(builtins[type].oid, format).load(data) assert rv == result