fix(editor): Format SQL uppercases words inside string literals, quoted identifiers and comments
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Read lib/core/actions/sql_script_format.dart and the existing scanner in lib/core/database/destructive_sql_detector.dart, then review test/core/actions/sql_script_format_test.dart and SqlQueryTabSession.formatSql in lib/features/workspace/sql_query_tab_session.dart. Coordinate with issue #1511 because it touches the same detector. Done means formatting changes SQL keywords only in code segments, preserves the caret position, and the listed literal, identifier, comment, escape, and unterminated-literal cases are covered by tests.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
Format SQL Query (command palette, Shift+Alt+F) calls formatSqlScript (lib/core/actions/sql_script_format.dart:64), which runs one regex over the whole text and uppercases every word found in _kSqlKeywords. It does not know about string literals, quoted identifiers or comments:
| Before | After | Effect |
|---|---|---|
WHERE status = 'not null' |
WHERE status = 'NOT NULL' |
query now matches different rows |
SELECT "order", "desc" FROM t |
SELECT "ORDER", "DESC" FROM t |
PostgreSQL: quoted identifiers are case-sensitive, the query fails (column does not exist) |
SELECT `limit` FROM t (MySQL) |
SELECT `LIMIT` FROM t |
changes the identifier on case-sensitive table names |
$$ ... begin ... end $$ (function body) |
body rewritten | changes stored code |
-- set in prod |
-- SET IN prod |
cosmetic |
The only test (test/core/actions/sql_script_format_test.dart) checks a literal with no keywords inside.
Also in SqlQueryTabSession.formatSql (lib/features/workspace/sql_query_tab_session.dart:102-108) the caret always jumps to the end of the document after formatting.
Fix
- Format only code segments. Scanning logic already exists in
DestructiveSqlDetector.stripCommentsAndStrings(lib/core/database/destructive_sql_detector.dart:213:--,/* */,$tag$,'...'), but it drops the segments and does not know"..."/`...`. Extract one lexical scanner that yields segments (code, string, quoted identifier, comment, dollar-quoted body) and use it in the formatter (and later in the stripper / splitter; coordinate with #1511 which touches the same detector). - Keep the caret where it was, mapped onto the new text. Keywords keep their length, so the offset is unchanged.
- Tests: each row of the table above, plus nested
''escapes and an unterminated literal.
- Lenguaje dominante
- Dart
- Estrellas
- 23
- Forks
- 1
- Merge medio
- 32 min
- PR fusionados (30 d)
- 537
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
- Tiene una 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 QueryaHub/Querya-Desktop
-
enhancement ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QueryaHub/Querya-Desktop#1689 ·
Los mantenedores suelen responder en 1 día
-
ui(dialogs): make destructive query and DML preview dialogs adaptive and prevent table name overflowAbiertobug frontend
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
QueryaHub/Querya-Desktop#1642 ·
Los mantenedores suelen responder en 1 día
-
bug error-handling settings
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
QueryaHub/Querya-Desktop#1637 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
QueryaHub/Querya-Desktop#1636 ·
Los mantenedores suelen responder en 1 día
-
enhancement marketplace
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QueryaHub/Querya-Desktop#1635 ·
Los mantenedores suelen responder en 1 día
Todos los issues de QueryaHub/Querya-Desktop
Issues similares
-
[FR] 缓存键放置在外面Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
bggRGjQaUbCoE/PiliPlus#3310 ·
Los mantenedores suelen responder en 1 día
-
package:code_builder type-bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 90/100
Los mantenedores suelen responder en 1 día
-
type:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
type-documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100
dart-lang/build#5229 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
photos
Dificultad 1/5 Menos de una hora Aptitud para principiantes 91/100
Los mantenedores suelen responder en 1 día