Skip to content

[sqlalchemy] Set supports_multivalues_insert=True #1024

Description

@sk-

Is your feature request related to a problem? Please describe.
We are migrating from https://github.com/xzkostyan/clickhouse-sqlalchemy and found that this project does not support SQLAlchemy's multi-row Insert.values(). This is because the dialect does not declare Dialect.supports_multivalues_insert:

conn.execute(t.insert().values([{"n": 1, "s": "a"}, {"n": 2, "s": "b"}]))
conn.execute(t.insert().values([(1, "a"), (2, "b")]))
conn.execute(t.insert().values([{"n": 1, "s": func.lower("A")}, {"n": 2, "s": func.lower("B")}]))
sqlalchemy.exc.CompileError: The 'clickhousedb' dialect with current database version settings does not support in-place multirow inserts.

This is surprising, given that ClickHouse itself accepts INSERT ... VALUES (...), (...). On the other hand the previously community maintained dialect and clickhouse-sqlalchemy enables the flag in drivers/base.py, so code written against it has to be rewritten when moving to clickhouse-connect.

Describe the solution you'd like
Set the flag next to the other supports_* attributes in cc_sqlalchemy/dialect.py:

     supports_native_decimal = True
     supports_native_boolean = True
+    supports_multivalues_insert = True
     supports_statement_cache = False

Describe alternatives you've considered
conn.execute(t.insert(), rows) (executemany) covers plain rows but not per-row SQL expressions, and requires rewriting existing call sites.

Additional context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions