A percent sign in a statement reaches the server doubled
評価
この issue はまだ評価されていません。
説明
SQLAlchemy writes a percent sign in a statement as %% when the driver takes %(name)s parameters, and the driver is expected to send one %. crate-python takes these parameters since 2.2.0, but its cursor sends %% to the server unchanged. sqlalchemy-cratedb uses them since 0.43.0, so from that release a percent sign in a statement arrives doubled (0.42.0 returns the right results):
# docker run -d --rm --name crate -p 4200:4200 crate:6.5.1 -Cdiscovery.type=single-node
# uv run --with sqlalchemy-cratedb==0.45.0 python repro.py
import sqlalchemy as sa
e = sa.create_engine("crate://localhost:4200")
with e.connect() as c:
# expected 'a%', actual 'a%%'
print(c.execute(sa.text("SELECT 'a%'")).scalar())
# expected 1, actual ProgrammingError: ParsingException ... 'SELECT 7 %%'
try:
print(c.execute(sa.select(sa.literal_column("7") % sa.literal_column("3"))).scalar())
except Exception as ex:
print(type(ex).__name__, str(ex).splitlines()[0])
# expected 'a%b', actual 'a%%b'
print(c.execute(sa.text("SELECT 'a%' || :x"), {"x": "b"}).scalar())
In DDL, server_default="100%" stores 100%%, and a table with Computed("id % 3") cannot be created. A value passed as a parameter is not affected.
The cursor shows it without SQLAlchemy:
# crate-python returns 'a%%b', psycopg returns 'a%b'
cursor.execute("SELECT 'a%%' || %(x)s", {"x": "b"})
When execute or executemany gets parameters as a dict, the cursor needs to turn %% into %, as psycopg does (SQLAlchemy passes an empty dict for a statement without parameters). A call without parameters needs no change, because psycopg leaves %% as it is there too.
- 主要言語
- Python
- スター
- 85
- フォーク
- 37
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crate/crate-python のほかの issue
-
[Security] tarfile.extractall without member validation in src/crate/testing/layer.py対応中かも @theluckystrike が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
crate/crate-python#794 · コメント 2 件 ·
-
cursor.description's type_code is always None, even though col_types is already available internally対応中かも @rnovatorov が 10 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
crate/crate-python#837 · コメント 2 件 ·
-
NUMERIC reads: full digits arrive, the decode drops them対応中かも @aminghadersohi が 69 日前に担当しました。 オープンbug
難易度 4/5 3〜5日 初心者へのやさしさ 52/100
crate/crate-python#826 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
crate/crate-python#751 · コメント 7 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
crate/crate-python#729 · コメント 1 件 ·
crate/crate-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
hugohe3/ppt-master#366 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 89/100
メンテナーはふだん 2 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
521xueweihan/HelloGitHub#4716 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
pcqpcq/open-source-android-apps#619 ·
メンテナーはふだん 1 日以内に返信
-
contribution Windows 主机
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Lee-xeo/Claude-Cage#1519 ·
メンテナーはふだん 1 日以内に返信