fix(editor): Format SQL uppercases words inside string literals, quoted identifiers and comments
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Dart
- Star
- 23
- Fork
- 1
- Merge trung bình
- 31 phút
- Pull request đã merge (30 ngày)
- 570
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của QueryaHub/Querya-Desktop
-
enhancement ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QueryaHub/Querya-Desktop#1689 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ui(dialogs): make destructive query and DML preview dialogs adaptive and prevent table name overflowĐang mởbug frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
QueryaHub/Querya-Desktop#1642 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug error-handling settings
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
QueryaHub/Querya-Desktop#1637 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
QueryaHub/Querya-Desktop#1636 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement marketplace
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
QueryaHub/Querya-Desktop#1635 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của QueryaHub/Querya-Desktop
Issue tương tự
-
[Bug] Web Guide has broken linksĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AppFlowy-IO/AppFlowy#9075 ·
-
Paste asks for iOS paste permission because the default context menu ignores SystemContextMenuCó thể đã có người làm @dorklein đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
maheshj01/searchfield#267 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
avdept/JellyBoxPlayer#375 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
basictech01/uniun#300 ·
Maintainer thường phản hồi trong vòng 1 ngày