Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not allowed to use float or int values in parameters #327

Closed
Siarhei-Hanchuk opened this issue Mar 28, 2024 · 1 comment · Fixed by #329
Closed

It is not allowed to use float or int values in parameters #327

Siarhei-Hanchuk opened this issue Mar 28, 2024 · 1 comment · Fixed by #329
Labels
bug Something isn't working

Comments

@Siarhei-Hanchuk
Copy link

Describe the bug

format_query_value ignores int and float data types. As result if query includes %(param)f or %(param)d, it crashes

Steps to reproduce

  1. run clickhouse docker run -d -p 8123:8123 clickhouse/clickhouse-server
  2. run Code example

Expected behaviour

Query is executed without any errors

Code example

import clickhouse_connect

client = clickhouse_connect.get_client(host="localhost")
client.query("SELECT initial_port FROM system.query_log WHERE initial_port > %(p_0)d", parameters={"p_0": 2})

clickhouse-connect and/or ClickHouse server logs

  File ".../lib/python3.11/site-packages/clickhouse_connect/driver/query.py", line 360, in finalize_query
    return query % {k: format_query_value(v, server_tz) for k, v in parameters.items()}

Configuration

Environment

  • clickhouse-connect version: 0.7.4
  • Python version: 3.11
  • Operating system: Linux

ClickHouse server

  • ClickHouse Server version: 24.3.1
@Siarhei-Hanchuk Siarhei-Hanchuk added the bug Something isn't working label Mar 28, 2024
@genzgd
Copy link
Collaborator

genzgd commented Mar 28, 2024

Thanks -- this is indeed broken. As a workaround you can use %s instead of %d until a fix is released

@genzgd genzgd linked a pull request Mar 28, 2024 that will close this issue
2 tasks
@genzgd genzgd closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants