Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.sql-formatter.json being ignored by CLI #787

Closed
musjj opened this issue Oct 18, 2024 · 1 comment · Fixed by #788
Closed

.sql-formatter.json being ignored by CLI #787

musjj opened this issue Oct 18, 2024 · 1 comment · Fixed by #788
Labels

Comments

@musjj
Copy link
Contributor

musjj commented Oct 18, 2024

Describe the bug

The .sql-formatter.json in the current directory is ignored, unless specified with --config:

$ cat .sql-formatter.json
{
  "language": "postgresql"
}

$ echo "SELECT 2 :: numeric AS foo;" | sql-formatter
Error: Parse error: Unexpected ":: numeric" at line 1 column 10.
This likely happens because you're using the default "sql" dialect.
If possible, please select a more specific dialect (like sqlite, postgresql, etc).

$ echo "SELECT 2 :: numeric AS foo;" | sql-formatter --config .sql-formatter.json
SELECT
  2::numeric AS foo;

I suspect that this is caused by this:

findConfig(dir = __dirname) {

Which means it defaults to searching in the installed directory instead of the current directory.

Expected behavior
.sql-formatter.json should be automatically read

Actual behavior
.sql-formatter.json is not automatically read

Usage

  • How are you calling / using the library?
    echo "SELECT 2 :: numeric AS foo;" | sql-formatter
  • What SQL language(s) does this apply to?
    PostgreSQL
  • Which SQL Formatter version are you using?
    15.4.2
@nene
Copy link
Collaborator

nene commented Oct 18, 2024

Fixed in 15.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants