Skip to content

Conversation

@noahd1
Copy link
Member

@noahd1 noahd1 commented Dec 12, 2025

The sqlfluff plugin script is defined as follows:

sqlfluff lint ${target} --format json --nofail --dialect ansi

When a dialect is specified as a command line option it takes precedence over the option in a configuration file. So if a repository has a configuration file defined as:

[sqlfluff]
dialect = postgres

The dialect will be ansi, ignoring the value in the configuration file. This PR intentionally introduces a failing test to demonstrate the behavior. The SQL in the PR is supposed to produce a lint issue (in postgres), but doesn't because the dialect is set to ansi.

The sqlfluff plugin's use of a --dialect ansi effectively creates a smart default; the sqlfluff linter itself does not have one. If you run sqlfluff (not the plugin), without a dialect (it can be passed as a command line argument or placed in a configuration file), sqlfluff raises an error.

A fix for this plugin issue should retain the smart default for backwards compatibility. While removing the --dialect ansi from the script directive will cause the linter to successfully honor the dialect in configuration files, it will raise an error for any users of the plugin who haven't specified a dialect.

One possible solution to maintain backwards compatibility would be initialize the plugin with a configuration file with a default dialect. This has its own issues -- e.g. if the customer has defined a dialect already, it should be honored. sqlfluff supports 5 different kinds of configuration files -- we could conditionally add the lowest precedent configuration file if it doesn't exist. In those cases it would be overridden by higher precedent configuration files, or not set if it already exists. This is pretty complex though.

Copilot AI review requested due to automatic review settings December 12, 2025 19:43
@github-actions
Copy link
Contributor

No issue mentions found. Please mention an issue in the pull request description.

Use GitHub automation to close the issue when a PR is merged

Copy link
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 demonstrates a configuration precedence issue in the sqlfluff plugin where the hardcoded --dialect ansi command-line argument overrides dialect settings specified in .sqlfluff configuration files.

  • Adds test fixtures showing that postgres-specific linting rules should be applied when a .sqlfluff config file specifies dialect = postgres
  • Creates a reproducible test case to validate the issue and verify future fixes

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
qlty-plugins/plugins/linters/sqlfluff/fixtures/postgres_config.in/test.sql Adds a simple SQL test file with double-quoted identifiers to demonstrate postgres-specific linting behavior
qlty-plugins/plugins/linters/sqlfluff/fixtures/postgres_config.in/.sqlfluff Adds sqlfluff configuration file specifying postgres dialect to test config file precedence
qlty-plugins/plugins/linters/sqlfluff/fixtures/__snapshots__/postgres_config_v3.5.0.shot Adds expected test output snapshot showing postgres-specific RF06 rule violations for unnecessary quoted identifiers

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

@qltysh
Copy link
Contributor

qltysh bot commented Dec 12, 2025

Qlty

Coverage Impact - ubuntu-latest

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@qltysh
Copy link
Contributor

qltysh bot commented Dec 12, 2025

Qlty

Coverage Impact - macos-15

⬇️ Merging this pull request will decrease total coverage on main by 0.01%.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

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.

2 participants