Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

fix(editor): Format SQL uppercases words inside string literals, quoted identifiers and comments

Đang mở
#1,566 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
dart, flutter, sql
Lĩnh vực
database

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ả

bug core editor P1 parser

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của QueryaHub/Querya-Desktop

Tất cả issue của QueryaHub/Querya-Desktop

Issue tương tự

Thêm issue về Dart

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.