Formatted SQL adds spaces inside the next string literal after a string ending in a backslash
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
- #6507 de @ayushdoesdev — cerrado sin fusionar
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 38/100
Línea de trabajo
Start in prqlc/prqlc/src/sql/mod.rs at sql::compile and trace how generated SQL is passed to sqlformat::format; inspect the sqlformat tokenizer behavior described in the issue. Compare the proposed options and add a regression test for the backslash-ending string example. Done means formatted output preserves the literal value; the issue leaves the interim approach and upstream report for maintainers to decide.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
When a string literal in the query ends with a backslash, the formatted SQL (the default output) changes the value of the next string literal by adding spaces inside its quotes. The query then compares against, or selects, a different string than the one written. --no-format output is correct.
prql target:sql.postgres
from files
filter path == 'C:\\' || name == 'readme'
prqlc compile --no-format, which is correct:
SELECT * FROM files WHERE path = 'C:\' OR name = 'readme'
prqlc compile:
SELECT
*
FROM
files
WHERE
path = 'C:\' OR name = ' readme '
name = ' readme ' matches no row that name = 'readme' would. The same happens with derive {a = 'ab\\', b = 'c'}, which emits ' c ' AS b, and with raw strings like r'x\'. Any string whose value ends in a backslash triggers it; the query doesn't have to be unusual.
Cause: sql::compile passes the SQL that sqlparser generates through sqlformat::format. The sqlformat 0.5.0 tokenizer (get_string_token in src/tokenizer.rs) always treats a backslash as an escape inside '...' and "...". So it reads 'C:\' as an unterminated string that runs on to the next '. The quotes then pair up wrongly, and the formatter adds spaces around tokens that are really inside string literals. In standard SQL, and in the Postgres, DuckDB, SQLite and generic dialects PRQL targets, a backslash is an ordinary character, so 'C:\' is a complete literal. FormatOptions::dialect (Generic / PostgreSql / SQLServer) doesn't change this, and 0.5.0 is the latest sqlformat release. I found no report of this in shssoichiro/sqlformat-rs.
Why this is an issue rather than a PR: the durable fix is upstream, in sqlformat's tokenizer, perhaps keyed on its dialect. Any interim change in prqlc is a trade-off a maintainer should pick:
- Skip formatting, and return the unformatted SQL, when the generated SQL contains a backslash. This is simple and can't corrupt values, but those queries lose their layout.
- Mask string literals before formatting and restore them afterwards. This keeps the layout, but adds a second tokenizer pass in prqlc.
Either change would come with a regression test like the example above. Filing the upstream report would also need a decision: the repo shows no agent-contribution policy, so per this repo's tend guidance it waits for a go-ahead here.
- Lenguaje dominante
- Rust
- Estrellas
- 10.9k
- Forks
- 261
- Merge medio
- 3 d 21 h
- PR fusionados (30 d)
- 84
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
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 PRQL/prql
-
Underscore does not work as expectedPosiblemente ocupada @prql-bot la tomó hace 1 día. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
PRQL/prql#6518 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
prqlc Debug Report HTML Does Not Escape Source File Name, Enabling Stored XSS via PRQLC_DEBUG_LOGAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
PRQL/prql#6502 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Add `.prql` to linguistAbiertofriendliness integrations
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
PRQL/prql#1636 · 2 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 3 días
-
Dificultad 4/5 1-2 días Aptitud para principiantes 12/100
PRQL/prql#6517 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
review-runs-tracking: 2026-11Abiertoreview-runs-tracking
Dificultad 3/5 Medio día Aptitud para principiantes 5/100
PRQL/prql#6513 · 1 comentario ·
Los mantenedores suelen responder en 3 días
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Rename SerVtdExt to ServtdExtAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
GiganticMinecraft/seichi-portal-backend#1651 ·
Los mantenedores suelen responder en 1 día
-
Android visitors are offered the Linux .deb on cap.so's homepage and download pagePosiblemente ocupada @patrickballard la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
CapSoftware/Cap#3677 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día