Files
zeekay 999d38466d rename: this fork is ours — datastore_connect
Imports read `datastore_connect`, distribution `datastore-connect`, so nothing has to
import another product's name to talk to Hanzo Datastore.

Cut from upstream 0.8.17 — the version this stack already ran — rather than from
upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from
HEAD would have dragged versions along with the name (connect alone jumped
0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing
a rename's clothes.

X-ClickHouse-* headers are untouched: they are wire protocol the server sends
and expects, and a different token shape from the module name.
2026-07-26 11:01:30 -07:00

27 lines
1.3 KiB
Python

from datastore_connect.driver.query import QueryContext
def test_copy_context():
settings = {'max_bytes_for_external_group_by': 1024 * 1024 * 100,
'read_overflow_mode': 'throw'}
parameters = {'user_id': 'user_1'}
query_formats = {'IPv*': 'string'}
context = QueryContext('SELECT source_ip FROM table WHERE user_id = %(user_id)s',
settings=settings,
parameters=parameters,
query_formats=query_formats,
use_none=True)
assert context.use_none is True
assert context.final_query == "SELECT source_ip FROM table WHERE user_id = 'user_1'"
assert context.query_formats['IPv*'] == 'string'
assert context.settings['max_bytes_for_external_group_by'] == 104857600
context_copy = context.updated_copy(
settings={'max_bytes_for_external_group_by': 1024 * 1024 * 24, 'max_execution_time': 120},
parameters={'user_id': 'user_2'}
)
assert context_copy.settings['read_overflow_mode'] == 'throw'
assert context_copy.settings['max_execution_time'] == 120
assert context_copy.settings['max_bytes_for_external_group_by'] == 25165824
assert context_copy.final_query == "SELECT source_ip FROM table WHERE user_id = 'user_2'"