fix(editor): Format SQL uppercases words inside string literals, quoted identifiers and comments
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Dart
- Stelle
- 23
- Fork
- 1
- Merge medio
- 32m
- PR unite (30g)
- 537
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un 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 QueryaHub/Querya-Desktop
-
enhancement ui
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
QueryaHub/Querya-Desktop#1689 ·
I maintainer di solito rispondono entro 1 giorno
-
ui(dialogs): make destructive query and DML preview dialogs adaptive and prevent table name overflowApertabug frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
QueryaHub/Querya-Desktop#1642 ·
I maintainer di solito rispondono entro 1 giorno
-
bug error-handling settings
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
QueryaHub/Querya-Desktop#1637 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
QueryaHub/Querya-Desktop#1636 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement marketplace
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
QueryaHub/Querya-Desktop#1635 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di QueryaHub/Querya-Desktop
Issue simili
-
area: ui feature priority: medium
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
AimesSoft/NipaPlay-Reload#1022 ·
I maintainer di solito rispondono entro 1 giorno
-
`jwtPayload.roomConfiguration` returns null fields for tokens from LiveKit server SDKsForse già presa @RaphaelFakhri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
livekit/client-sdk-flutter#1243 ·
I maintainer di solito rispondono entro 1 giorno
-
bug to check
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
zjs81/meshcore-open#602 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno