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

Cut from upstream 0.2.9 — 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:28 -07:00

35 lines
1.1 KiB
Python

import logging
from ..writer import write_binary_str, write_binary_uint8
from .available import settings as available_settings
logger = logging.getLogger(__name__)
class SettingsFlags:
IMPORTANT = 0x1
CUSTOM = 0x2
def write_settings(settings, buf, settings_as_strings, flags):
for setting, value in (settings or {}).items():
# If the server support settings as string we do not need to know
# anything about them, so we can write any setting.
if settings_as_strings:
write_binary_str(setting, buf)
write_binary_uint8(flags, buf)
write_binary_str(str(value), buf)
else:
# If the server requires string in binary,
# then they cannot be written without type.
setting_writer = available_settings.get(setting)
if not setting_writer:
logger.warning('Unknown setting %s. Skipping', setting)
continue
write_binary_str(setting, buf)
setting_writer.write(value, buf)
write_binary_str('', buf) # end of settings