A percent sign in a statement reaches the server doubled
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 85
- Fork
- 37
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di crate/crate-python
-
[Security] tarfile.extractall without member validation in src/crate/testing/layer.pyForse già presa @theluckystrike l’ha presa 2 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
crate/crate-python#794 · 2 commenti ·
-
cursor.description's type_code is always None, even though col_types is already available internallyForse già presa @rnovatorov l’ha presa 10 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
crate/crate-python#837 · 2 commenti ·
-
NUMERIC reads: full digits arrive, the decode drops themForse già presa @aminghadersohi l’ha presa 69 giorni fa. Apertabug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
crate/crate-python#826 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
crate/crate-python#751 · 7 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
crate/crate-python#729 · 1 commento ·
Tutte le issue di crate/crate-python
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
hugohe3/ppt-master#366 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 89/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
521xueweihan/HelloGitHub#4716 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 84/100
pcqpcq/open-source-android-apps#619 ·
I maintainer di solito rispondono entro 1 giorno
-
contribution Windows 主机
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
Lee-xeo/Claude-Cage#1519 ·
I maintainer di solito rispondono entro 1 giorno