Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions asynch/proto/streams/buffered.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ def __init__(
async def flush(self):
await self.compressor.write(self.buffer)
self.position = 0
self.buffer = bytearray()


class CompressedBufferedReader(BufferedReader):
Expand Down
16 changes: 14 additions & 2 deletions tests/test_proto/test_proto_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
from asynch.proto.cs import ServerInfo


@pytest.fixture()
async def proto_conn(config) -> AsyncIterator[ProtoConnection]:
@pytest.fixture(params=[False, "lz4", "zstd"])
async def proto_conn(request, config) -> AsyncIterator[ProtoConnection]:
_conn = ProtoConnection(
user=config.user,
password=config.password,
host=config.host,
port=config.port,
database=config.database,
compression=request.param,
)
await _conn.connect()
yield _conn
Expand Down Expand Up @@ -103,6 +104,17 @@ async def test_execute_with_missing_arg(proto_conn: ProtoConnection):
await proto_conn.execute(query, args={"foo": 1})


@pytest.mark.asyncio
async def test_large_insert(proto_conn: ProtoConnection):
data = [(1,)] * 10_000
async with create_table(proto_conn, "a Int64"):
await proto_conn.execute(
"INSERT INTO test.test (a) VALUES", data, settings={"insert_block_size": 1000}
)
rv = await proto_conn.execute("SELECT * FROM test.test")
assert rv == data


@asynccontextmanager
async def create_table(connection, spec):
await connection.execute("DROP TABLE IF EXISTS test.test")
Expand Down