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

prettier-plugin-sql handling of sql-formatter errors #395

Open
tylersayshi opened this issue Nov 14, 2024 · 0 comments
Open

prettier-plugin-sql handling of sql-formatter errors #395

tylersayshi opened this issue Nov 14, 2024 · 0 comments

Comments

@tylersayshi
Copy link

Is it possible to either by default or by configuration have the plugin throw a prettier error when invalid sql is found?

Maybe there is a better way to handle this, but currently the error is thrown in the prettier process, but prettier's checks still pass.

partial error:

A RESERVED_PHRASE token based on:
    keyword$subexpression$1 →  ● %RESERVED_PHRASE
    keyword →  ● keyword$subexpression$1
    atomic_expression$subexpression$1 →  ● keyword
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    expressions_or_clauses$ebnf$1 → expressions_or_clauses$ebnf$1 ● free_form_sql
    expressions_or_clauses →  ● expressions_or_clauses$ebnf$1 expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1
A RESERVED_JOIN token based on:
    keyword$subexpression$1 →  ● %RESERVED_JOIN
    keyword →  ● keyword$subexpression$1
    atomic_expression$subexpression$1 →  ● keyword
    atomic_expression →  ● atomic_expression$subexpression$1
    asteriskless_andless_expression$subexpression$1 →  ● atomic_expression
    asteriskless_andless_expression →  ● asteriskless_andless_expression$subexpression$1
    asteriskless_free_form_sql$subexpression$1 →  ● asteriskless_andless_expression
    asteriskless_free_form_sql →  ● asteriskless_free_form_sql$subexpression$1
    free_form_sql$subexpression$1 →  ● asteriskless_free_form_sql
    free_form_sql →  ● free_form_sql$subexpression$1
    expressions_or_clauses$ebnf$1 → expressions_or_clauses$ebnf$1 ● free_form_sql
    expressions_or_clauses →  ● expressions_or_clauses$ebnf$1 expressions_or_clauses$ebnf$2
    statement →  ● expressions_or_clauses statement$subexpression$1
    main$ebnf$1 → main$ebnf$1 ● statement
    main →  ● main$ebnf$1

    at Parser.feed (~/gitspace/falcon/node_modules/nearley/lib/nearley.js:343:27)
    at Object.parse (file:///~/gitspace/falcon/node_modules/sql-formatter/dist/index.js:16813:34)
    at Formatter.parse (file:///~/gitspace/falcon/node_modules/sql-formatter/dist/index.js:17522:49)
    at Formatter.format (file:///~/gitspace/falcon/node_modules/sql-formatter/dist/index.js:17517:22)
    at formatDialect (file:///~/gitspace/falcon/node_modules/sql-formatter/dist/index.js:17640:57)
    at format (file:///~/gitspace/falcon/node_modules/sql-formatter/dist/index.js:17630:10)
    at Object.print (file:///~/gitspace/falcon/node_modules/prettier-plugin-sql/lib/index.js:41:31)
    at callPluginPrintFunction (file:///~/gitspace/falcon/node_modules/prettier/index.mjs:20871:20)
    at printAstToDoc (file:///~/gitspace/falcon/node_modules/prettier/index.mjs:20826:22)
    at async textToDoc (file:///~/gitspace/falcon/node_modules/prettier/index.mjs:20793:16) {
  offset: 8,
  token: {
    type: 'CLOSE_PAREN',
    raw: ')',
    text: ')',
    start: 40,
    precedingWhitespace: '\n'
  }
}
All matched files use Prettier code style!
@tylersayshi tylersayshi changed the title prettier-plugin-sql prettier-plugin-sql handling of sql-formatter errors Nov 14, 2024
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

No branches or pull requests

1 participant