) -> Tuple[Any, ...]:
...
- def load(self, data: bytes, oid: int, format: Format = Format.TEXT) -> Any:
- ...
-
def get_load_function(self, oid: int, format: Format) -> LoadFunc:
...
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:
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: ...
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:
@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"),
)
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