return self._types
@property
- def types_names(self):
+ def types_names_sql(self):
if self._types_names:
return self._types_names
self._types_names = types
return types
+ @property
+ def types_names(self):
+ types = [
+ t.as_string(self.conn).replace('"', "")
+ for t in self.types_names_sql
+ ]
+ return types
+
def _get_type_name(self, tx, schema, value):
# Special case it as it is passed as unknown so is returned as text
if schema == (list, str):
@property
def create_stmt(self):
fields = []
- for name, type in zip(self.fields_names, self.types_names):
+ for name, type in zip(self.fields_names, self.types_names_sql):
fields.append(sql.SQL("{} {}").format(name, type))
fields = sql.SQL(", ").join(fields)
@pytest.mark.slow
-@pytest.mark.parametrize("fmt", [Format.TEXT, Format.BINARY])
+@pytest.mark.parametrize(
+ "fmt, set_types",
+ [(Format.TEXT, True), (Format.TEXT, False), (Format.BINARY, True)],
+)
@pytest.mark.parametrize("method", ["read", "iter", "row", "rows"])
-def test_copy_to_leaks(dsn, faker, fmt, method, retries):
+def test_copy_to_leaks(dsn, faker, fmt, set_types, method, retries):
faker.format = PyFormat.from_pq(fmt)
faker.choose_schema(ncols=20)
faker.make_records(20)
)
with cur.copy(stmt) as copy:
- types = [
- t.as_string(conn).replace('"', "")
- for t in faker.types_names
- ]
- copy.set_types(types)
+ if set_types:
+ copy.set_types(faker.types_names)
if method == "read":
while 1:
@pytest.mark.slow
-@pytest.mark.parametrize("fmt", [Format.TEXT, Format.BINARY])
-def test_copy_from_leaks(dsn, faker, fmt, retries):
+@pytest.mark.parametrize(
+ "fmt, set_types",
+ [(Format.TEXT, True), (Format.TEXT, False), (Format.BINARY, True)],
+)
+def test_copy_from_leaks(dsn, faker, fmt, set_types, retries):
faker.format = PyFormat.from_pq(fmt)
faker.choose_schema(ncols=20)
faker.make_records(20)
sql.SQL(fmt.name),
)
with cur.copy(stmt) as copy:
+ if set_types:
+ copy.set_types(faker.types_names)
for row in faker.records:
copy.write_row(row)
@pytest.mark.slow
-@pytest.mark.parametrize("fmt", [Format.TEXT, Format.BINARY])
+@pytest.mark.parametrize(
+ "fmt, set_types",
+ [(Format.TEXT, True), (Format.TEXT, False), (Format.BINARY, True)],
+)
@pytest.mark.parametrize("method", ["read", "iter", "row", "rows"])
-async def test_copy_to_leaks(dsn, faker, fmt, method, retries):
+async def test_copy_to_leaks(dsn, faker, fmt, set_types, method, retries):
faker.format = PyFormat.from_pq(fmt)
faker.choose_schema(ncols=20)
faker.make_records(20)
)
async with cur.copy(stmt) as copy:
- types = [
- t.as_string(conn).replace('"', "")
- for t in faker.types_names
- ]
- copy.set_types(types)
+ if set_types:
+ copy.set_types(faker.types_names)
if method == "read":
while 1:
@pytest.mark.slow
-@pytest.mark.parametrize("fmt", [Format.TEXT, Format.BINARY])
-async def test_copy_from_leaks(dsn, faker, fmt, retries):
+@pytest.mark.parametrize(
+ "fmt, set_types",
+ [(Format.TEXT, True), (Format.TEXT, False), (Format.BINARY, True)],
+)
+async def test_copy_from_leaks(dsn, faker, fmt, set_types, retries):
faker.format = PyFormat.from_pq(fmt)
faker.choose_schema(ncols=20)
faker.make_records(20)
sql.SQL(fmt.name),
)
async with cur.copy(stmt) as copy:
+ if set_types:
+ copy.set_types(faker.types_names)
for row in faker.records:
await copy.write_row(row)