Skip to content

feat: auto-fix naked identifiers when prefer_quoted_identifiers is enabled (RF06)#2599

Open
Copilot wants to merge 5 commits intomainfrom
copilot/add-automatic-quoted-identifier-formatting
Open

feat: auto-fix naked identifiers when prefer_quoted_identifiers is enabled (RF06)#2599
Copilot wants to merge 5 commits intomainfrom
copilot/add-automatic-quoted-identifier-formatting

Conversation

Copy link
Copy Markdown

Copilot AI commented May 4, 2026

Rule RF06 (references.quoting) could detect unquoted identifiers when prefer_quoted_identifiers = true but couldn't fix them — the violations were reported with an empty fix list.

Changes

  • rf06.rs: Added LintFix::replace in the prefer_quoted_identifiers branch, wrapping NakedIdentifier segments in dialect-appropriate quotes via two new helpers:
    • identifier_quote_chars(dialect) — maps dialect → (open, close) quote pair
    • make_quoted_identifier(dialect, contents, id) — builds the QuotedIdentifier segment
  • RF06.yml: Added fix_str to all 9 previously unfixable test_fail_*_prefer_quoted_* cases

Quote character mapping

Dialect Before After
ANSI, Postgres, Snowflake, … name "name"
T-SQL name [name]
BigQuery, MySQL, SparkSQL name `name`

Example

-- Input
SELECT name FROM users

-- sqruff fix (ANSI, prefer_quoted_identifiers = true)
SELECT "name" FROM "users"

Copilot AI changed the title [WIP] Add option for automatically quoted identifier in formatting feat: auto-fix naked identifiers when prefer_quoted_identifiers is enabled (RF06) May 4, 2026
Copilot AI requested a review from gvozdvmozgu May 4, 2026 19:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Benchmark for 9cee641

Click to view benchmark
Test Base PR %
DepthMap::from_parent 59.1±1.12µs 58.5±0.85µs -1.02%
fix_complex_query 12.3±0.09ms 12.4±0.06ms +0.81%
fix_superlong 203.7±7.85ms 204.3±3.67ms +0.29%
parse_complex_query 4.2±0.20µs 4.2±0.11µs 0.00%
parse_expression_recursion 7.2±0.17µs 7.3±0.13µs +1.39%
parse_simple_query 1053.1±24.86ns 1062.1±10.99ns +0.85%

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 4, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing copilot/add-automatic-quoted-identifier-formatting (8b80f41) with main (f20b401)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@gvozdvmozgu gvozdvmozgu marked this pull request as ready for review May 4, 2026 21:05
@gvozdvmozgu gvozdvmozgu requested a review from Copilot May 4, 2026 21:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables auto-fixing for rule RF06 (references.quoting) when prefer_quoted_identifiers = true by generating replacement segments that wrap naked identifiers in dialect-appropriate quotes. It also updates the RF06 fixture cases to assert the new fixes and removes outdated documentation stating the mode isn’t fix-compatible.

Changes:

  • Add a LintFix::replace for the prefer_quoted_identifiers branch in RF06 to quote NakedIdentifier segments.
  • Introduce helper functions to choose quote characters by dialect and build a QuotedIdentifier segment.
  • Update RF06 YAML fixtures with fix_str for previously unfixable cases and remove the “not fix compatible” note from the docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
docs/reference/rules.md Removes outdated note claiming prefer_quoted_identifiers mode is not fix-compatible.
crates/lib/test/fixtures/rules/std_rule_cases/RF06.yml Adds expected fix_str outputs for prefer_quoted_identifiers failures (ANSI/TSQL/BigQuery).
crates/lib/src/rules/references/rf06.rs Implements fixes for naked identifiers under prefer_quoted_identifiers and adds dialect quote helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/lib/src/rules/references/rf06.rs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Benchmark for daeb214

Click to view benchmark
Test Base PR %
DepthMap::from_parent 61.6±0.56µs 60.9±2.55µs -1.14%
fix_complex_query 12.7±0.04ms 13.0±0.05ms +2.36%
fix_superlong 173.7±3.29ms 179.9±8.16ms +3.57%
parse_complex_query 4.5±0.04µs 4.4±0.08µs -2.22%
parse_expression_recursion 7.6±0.11µs 7.5±0.07µs -1.32%
parse_simple_query 1102.8±20.35ns 1065.9±13.06ns -3.35%

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.

Option to automatically quoted identifier in formatting

3 participants