From 4eca40a16b4cfee5910ace92c1f98ca218f5cd26 Mon Sep 17 00:00:00 2001 From: Steve Dignam Date: Wed, 8 Oct 2025 22:30:30 -0400 Subject: [PATCH] lsp: don't use ansi codes in output --- PLAN.md | 21 ++++++++++++++++++++- crates/squawk/src/main.rs | 8 +++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/PLAN.md b/PLAN.md index ffebe192..15548526 100644 --- a/PLAN.md +++ b/PLAN.md @@ -73,7 +73,7 @@ example: ```sql -- some query comment -SELECT name username, email, +SELECT name username, "email", "weird-column-name" FROM bar ``` @@ -96,6 +96,7 @@ config ideas: - lower / upper case keywords (default lowercase) - indent (default 2) +- quoted idents (default avoid) links: @@ -421,12 +422,30 @@ related: https://eslint.style/rules/no-extra-parens should support various fixes so people can write in one dialect of SQL and have it easily convert to the other one +### Rule: group by all + +[requires pg >=19](https://www.depesz.com/2025/10/02/waiting-for-postgresql-19-add-group-by-all/) + +```sql +SELECT customer_id, merchant_id, request_id, count(*) from t +group by 1, 2, 3; +-- ^^^^^^^ implicit group by all +``` + +becomes: + +```sql +SELECT customer_id, merchant_id, request_id, count(*) from t +group by all; +``` + ### Rule: unused column ```sql SELECT customer_id, total_amount FROM ( SELECT customer_id, SUM(amount) AS total_amount, min(created_at) +-- ^^^^^^^^^^^^^^^ unused FROM orders GROUP BY customer_id ) AS customer_totals diff --git a/crates/squawk/src/main.rs b/crates/squawk/src/main.rs index 87e4e9ca..6bef6215 100644 --- a/crates/squawk/src/main.rs +++ b/crates/squawk/src/main.rs @@ -168,11 +168,17 @@ Please open an issue at https://github.com/sbdchd/squawk/issues/new with the log let opts = Opt::parse(); if opts.verbose { + // ANSI codes don't render properly in the VSCode output pane + let color_choice = if matches!(opts.cmd, Some(Command::Server)) { + simplelog::ColorChoice::Never + } else { + simplelog::ColorChoice::Auto + }; CombinedLogger::init(vec![simplelog::TermLogger::new( simplelog::LevelFilter::Info, simplelog::Config::default(), simplelog::TerminalMode::Stderr, - simplelog::ColorChoice::Auto, + color_choice, )]) .expect("problem creating logger"); }