Skip to content

Comments

Fix format query to preserve identifier case#833

Open
r-cha wants to merge 1 commit intotconbeer:mainfrom
r-cha:fix-format-preserves-case
Open

Fix format query to preserve identifier case#833
r-cha wants to merge 1 commit intotconbeer:mainfrom
r-cha:fix-format-preserves-case

Conversation

@r-cha
Copy link

@r-cha r-cha commented Sep 5, 2025

Description

This PR fixes #817 where the Format Query function was converting all identifiers (table names, column names, etc.) to lowercase, potentially breaking queries that rely on case-sensitive identifiers.

Problem

Previously, when using Format Query:

  • SELECT FirstName FROM UserTable would become select firstname from usertable
  • This could break queries in case-sensitive databases or when using quoted identifiers

Solution

Changed the sqlfmt Mode configuration to use the 'clickhouse' dialect instead of the default 'polyglot' dialect. The ClickHouse dialect preserves case of user-defined identifiers (table names, column names, function names) but is otherwise identical to the previous behavior.

- Changed sqlfmt Mode to use 'clickhouse' dialect instead of default 'polyglot'
- ClickHouse dialect preserves case of table names, column names, and other identifiers
- SQL keywords are still formatted to lowercase as expected
- Added test to verify identifier case preservation
- Fixes issue where Format Query (F4) would break case-sensitive queries

Fixes tconbeer#813

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-446eb4fc-ccaf-462a-9848-155ee06dd5f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Format Query changes capitalization

1 participant