Provide a NamedDateValue alternative for unnamed placeholders (?) #1521
mirout
started this conversation in
Feature requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently in the clickhouse-go driver, using positional query parameters (?) with time.Time values defaults to ClickHouse DateTime type, which does not support millisecond/nanosecond precision. Preserving the timestamp precision (e.g., milliseconds or microseconds with DateTime64) requires the usage of named parameters combined with the clickhouse.DateNamed() helper.
This behavior can create confusion for users because they might assume that positional placeholders handle correct precision for created DateTime64(3) fields.
Example of the current limitation
Positional parameter usage (precision lost):
This inserts into a DateTime64 column, but stores timestamp without milliseconds precision due to implicit type binding and defaults to DateTime.
Named parameter workaround (precision preserved):
The named parameter with clickhouse.DateNamed() explicitly preserves millisecond precision. However, using named parameters everywhere can be verbose.
Suggestion / Proposed Solution
I suggest adding a new simplified unnamed placeholder helper or option to directly handle DateTime64 types and preserve precision without needing explicitly named parameters. For example, something along these lines:
Beta Was this translation helpful? Give feedback.
All reactions