Skip to content

Migrate to paramstyle="pyformat", following crate-python 2.2.0#266

Open
amotl wants to merge 14 commits into
mainfrom
paramstyle-pyformat
Open

Migrate to paramstyle="pyformat", following crate-python 2.2.0#266
amotl wants to merge 14 commits into
mainfrom
paramstyle-pyformat

Conversation

@amotl

@amotl amotl commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

About

A few adjustments were necessary to accommodate the test suite to upstream changes in crate-python 2.2.0. The updates show that the improvement might have an impact to downstream users, so we might want to handle it with more care even in retrospective.

References

@coderabbitai

This comment was marked as spam.

@amotl

amotl commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi @bgunebakan. Please let me know if you think it makes sense to take over this PR, or otherwise close it without much ado at your disposal if relevant fixes are coming from upstream crate-python, so this patch might no longer be needed. Thanks!

@bgunebakan bgunebakan self-assigned this Jun 9, 2026
Comment thread tests/dict_test.py
Comment thread pyproject.toml Outdated
@bgunebakan bgunebakan marked this pull request as ready for review June 10, 2026 08:33
Comment thread pyproject.toml Outdated
dependencies = [
"backports.zoneinfo<1; python_version<'3.9'",
"crate>=2,<3",
"crate>=2.2.1b2,<3",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMPORTANT: upgrade to stable version 2.2.1

Suggested change
"crate>=2.2.1b2,<3",
"crate>=2.2.1,<3",

@amotl amotl left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. Thank you for adjusting my patch properly. Maybe announce some of the changes as "breaking"?

Comment thread tests/dict_test.py
Comment thread tests/update_test.py
Comment thread tests/vector_test.py

@kneth kneth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good change, but we need to explain it carefully in CHANGES.md as it has a big impact for the users' code.

@amotl

amotl commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

[The change] has a big impact for the users' code.

Maybe bring in a major version bump at the same time to signal this?

@bgunebakan

Copy link
Copy Markdown
Contributor

It is a good change, but we need to explain it carefully in CHANGES.md as it has a big impact for the users' code.

Thanks, I extended CHANGES.md file with more info about breaking changes.

@mfussenegger mfussenegger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a suggestion for the changes entry.

Otherwise lgtm - but would be great if this could be squashed into 2 commits: One that drops support for the outdated python versions and another one that bumps crate-python + makes the pyformat changes.

Comment thread CHANGES.md
Comment on lines +17 to +38
- Migrated to `paramstyle="pyformat"`, following crate-python 2.2.1.

**Breaking change:** The dialect now generates `%(name)s` named placeholders
and passes a `dict` of parameters to the DBAPI cursor, instead of the previous
`?` positional placeholders with a `tuple`. crate-python converts these to
CrateDB's native `$N` positional markers before sending over HTTP, so no
server-side changes are required.

User impact:

- **ORM / Core users**: No action required. SQLAlchemy handles parameter
binding transparently; existing application code continues to work unchanged.
- **Direct cursor users** who log or inspect the SQL string passed to
`cursor.execute()` will observe `%(name)s` placeholders instead of `?`.
- **Partial `ObjectType` updates** generate subscript-assignment SQL with named
parameters, e.g. `SET data['x'] = %(data_'x'_)s`, replacing the previous
positional form `SET data['x'] = ?`.
- **`pandas` / Dask `DataFrame.to_sql(..., method=insert_bulk)`** continues to
work. The bulk-operations path sends `$N` positional SQL to CrateDB, with
conversion handled by crate-python ≥ 2.2.1.
- **Minimum Python version raised to 3.10.** crate-python 2.1.0+ requires
Python ≥ 3.10. Python 3.6–3.9 are no longer supported.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Migrated to `paramstyle="pyformat"`, following crate-python 2.2.1.
**Breaking change:** The dialect now generates `%(name)s` named placeholders
and passes a `dict` of parameters to the DBAPI cursor, instead of the previous
`?` positional placeholders with a `tuple`. crate-python converts these to
CrateDB's native `$N` positional markers before sending over HTTP, so no
server-side changes are required.
User impact:
- **ORM / Core users**: No action required. SQLAlchemy handles parameter
binding transparently; existing application code continues to work unchanged.
- **Direct cursor users** who log or inspect the SQL string passed to
`cursor.execute()` will observe `%(name)s` placeholders instead of `?`.
- **Partial `ObjectType` updates** generate subscript-assignment SQL with named
parameters, e.g. `SET data['x'] = %(data_'x'_)s`, replacing the previous
positional form `SET data['x'] = ?`.
- **`pandas` / Dask `DataFrame.to_sql(..., method=insert_bulk)`** continues to
work. The bulk-operations path sends `$N` positional SQL to CrateDB, with
conversion handled by crate-python ≥ 2.2.1.
- **Minimum Python version raised to 3.10.** crate-python 2.1.0+ requires
Python ≥ 3.10. Python 3.6–3.9 are no longer supported.
- The dialect now uses `paramstyle = "pyformat"` supported in crate-python 2.2.1.
Because of this the SQL statements logged or inspected will contain
`%(name)s` placeholders instead of `?`.
- Removed support for Python versions < 3.11

Mentioning 3 internal changes that basically boil down to "nothing changes for the user" seems a bit too verbose.

Out of curiosity: Was this LLM generated?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi. I had the impression the change would cause some breaking changes, so I requested them being mentioned within the changelog. Apologies if this is not the case at all.

@bgunebakan bgunebakan Jun 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioning 3 internal changes that basically boil down to "nothing changes for the user" seems a bit too verbose.

Out of curiosity: Was this LLM generated?

I gathered information with LLM and build the list based on changes.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants