LargeBinary binds or raises depending on whether the value happens to be valid UTF-8
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Comienza localizando el punto de entrada de la representación de parámetros o literales del dialecto y el manejo existente de LargeBinary. Reproduce los ejemplos de UTF-8 no válido y, después, implementa la representación hex/unhex sugerida para bytes. Se considera terminado cuando los valores binarios, incluido b'\x00\xff', se insertan y se recuperan idénticamente sin depender de la validez de UTF-8.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Versions
- databend-sqlalchemy 0.5.5
- databend-driver 0.34.2
- SQLAlchemy 2.0.51
- Python 3.12.9, macOS
- Server:
datafuselabs/databend:v1.2.925-patch-4in Docker
What happens
The dialect renders parameters into the statement text, so a bytes value gets decoded as UTF-8 on the way in. Whether a LargeBinary insert works therefore depends on the value, not the type. One value at a time, everything else held constant:
| value | valid UTF-8 | result |
|---|---|---|
b'\x00\x01' |
yes | binds, round-trips identically |
b'abc' |
yes | binds, round-trips identically |
b'\xc3\xa9' |
yes | binds, round-trips identically |
b'\x00\xff' |
no | 'utf-8' codec can't decode byte 0xff in position 1 |
b'\xff' |
no | same |
b'\x80' |
no | same |
The database is not the problem. A BINARY column given unhex('00ff') reads back as b'\x00\xff' without complaint.
Why this one bothered me
Valid UTF-8 isn't a property binary data has. So the column works right up until the day the bytes have a high one in them — and a test suite with ASCII-ish fixtures will never see it. That's worse than a flat refusal, because a refusal gets found on day one. I ended up declaring LargeBinary unstorable on this dialect rather than let it fail per value, which loses a column type the database supports perfectly well.
Suggested fix
Hex-encode bytes parameters and emit unhex('…') — the server already accepts that, as above.
Some background, in case it's useful: databendlabs/bendsql#583 asked for real parameter binding in the driver, and interpolating into statement text is what makes bytes unrepresentable here. For what it's worth, trino-python-client gets this wrong from the identical cause — its literal formatter calls .encode() on the value, which is what you'd do to a str. Interpolating parameters into SQL seems to be what gets bytes wrong, whoever does it.
- Lenguaje dominante
- Python
- Estrellas
- 15
- Forks
- 5
- Merge medio
- 1 d 15 h
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de databendlabs/databend-sqlalchemy
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Index.create() reports success and creates nothing: the compiler emits an empty string and the connector returns earlyPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
do_rollback() swallows the connector's NotSupportedError, so a rollback reports success over a write that standsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Time is rendered as DATETIME, so a time-of-day is silently stored as a 1970-01-01 timestampPosiblemente ocupada @dwaddle la tomó hace 12 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
databendlabs/databend-sqlalchemy#58 · 1 comentario ·
Todos los issues de databendlabs/databend-sqlalchemy
Issues similares
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retriesAbiertofollow-up
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
Built-in QUBO fallback applies bitwise xor to floating binary statesPosiblemente ocupada @iloveeyjafjalla la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
qboson/kaiwu-pytorch-plugin#1702 ·
Los mantenedores suelen responder en 3 días
-
bug v2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
modelcontextprotocol/python-sdk#3811 ·
Los mantenedores suelen responder en 1 día
-
cost:cheap practicality:seen-in-the-wild severity:medium
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
fairagro/m4.2_advanced_middleware_api#620 ·
Los mantenedores suelen responder en 1 día