clickhouse.rs icon indicating copy to clipboard operation
clickhouse.rs copied to clipboard

with_param

Open serprex opened this issue 1 year ago • 3 comments

Small wrapper around with_option for impl Serialize + Bind

serprex avatar Sep 24 '24 13:09 serprex

Aside from the simpler types, the following needs testing:

  • Arrays, Maps, Tuples (e.g., common container types that make sense to use in this context).
  • DateTime/DateTime64 (IIRC, it requires a specific format like 2022-05-02 13:25:55.123456789, i.e. not exactly ISO timestamp)
  • Numeric and named enums
  • \t, \r, \n, single quotes, backslashes in the bound strings
  • Strings with UTF8 symbols
  • Nulls

I'd maybe also not mix it with .with_option method; the proposal from @mshustov looks better IMO (see this comment) - we can add the param_ prefix ourselves internally.

slvrtrn avatar Sep 24 '24 14:09 slvrtrn

So already found issue with basic tests. String Bind serializes to 'string' with quotes which is correct when interpolating into query string, but for server side parameters the string should be unquoted

Note once a string is contained it is expected to be quoted in params: https://github.com/ClickHouse/clickhouse-connect/issues/159

serprex avatar Sep 24 '24 15:09 serprex

We also need tests for UUID (probably, with the human-readable mode it works already). Also, for some implementation of DecimalX (the fixnum crate for instance).

And need to add some examples.

loyd avatar Sep 29 '24 08:09 loyd

@loyd, I'd like to merge this one. WDYT?

slvrtrn avatar Nov 04 '24 17:11 slvrtrn