A percent sign in a statement reaches the server doubled
Đánh giá
Issue này chưa được đánh giá.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 85
- Fork
- 37
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của crate/crate-python
-
[Security] tarfile.extractall without member validation in src/crate/testing/layer.pyCó thể đã có người làm @theluckystrike đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
crate/crate-python#794 · 2 bình luận ·
-
cursor.description's type_code is always None, even though col_types is already available internallyCó thể đã có người làm @rnovatorov đã nhận 10 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
crate/crate-python#837 · 2 bình luận ·
-
NUMERIC reads: full digits arrive, the decode drops themCó thể đã có người làm @aminghadersohi đã nhận 69 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
crate/crate-python#826 · 1 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
crate/crate-python#751 · 7 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
crate/crate-python#729 · 1 bình luận ·
Tất cả issue của crate/crate-python
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
hugohe3/ppt-master#366 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 89/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[开源推荐] 用 Claude 搭的 A 股投研与盘中作战系统Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
521xueweihan/HelloGitHub#4716 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
pcqpcq/open-source-android-apps#619 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
contribution Windows 主机
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Lee-xeo/Claude-Cage#1519 ·
Maintainer thường phản hồi trong vòng 1 ngày