Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ sha2 = "0.10"
similar = "2"
sqlclean = { path = "crates/sqlclean" }
# SQLQuack's formatter and lint engine, and the tokens and trees they read, which replace Polyglot.
sqlquack-fingerprint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] }
sqlquack-format = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlserver"] }
sqlquack-lint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite"] }
sqlquack-parse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293" }
sqlquack-syntax = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293" }
sqlquack-syntax-sqlserver = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "f53c6a076ad05c5c12047a2dcc9c58e3ddfbe293" }
sqlquack-fingerprint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite", "sqlserver"] }
sqlquack-format = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlserver"] }
sqlquack-lint = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da", features = ["bigquery", "databricks", "duckdb", "postgres", "snowflake", "sqlite"] }
sqlquack-parse = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da" }
sqlquack-syntax = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da" }
sqlquack-syntax-sqlserver = { git = "https://github.com/sqlstack-io/sqlquack.git", rev = "56c7c15ecafe61ea6650159469234db670dea8da" }

[workspace.lints.rust]
unsafe_code = "forbid"
Expand Down
118 changes: 3 additions & 115 deletions crates/sqlclean/src/sql_lint/tests/fixtures/sqlquack_departures.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,90 +223,13 @@
"reason": "A set operation's ORDER BY puts its items on the next line, as in every other dialect and SQL Server's own `ORDER BY\\n 1`; SQLClean kept them on the ORDER BY line",
"receipt": null
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t TABLESAMPLE (10 PERCENT)",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a TABLESAMPLE clause opaque (gap `tablesample`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t TABLESAMPLE (20 ROWS)",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a TABLESAMPLE clause opaque (gap `tablesample`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t TABLESAMPLE (10 PERCENT) REPEATABLE (123)",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a TABLESAMPLE clause opaque (gap `tablesample`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t WHERE NOT c",
"formatted": null,
"reason": "SQL Server rejects it: `An expression of non-boolean type specified in a context where a condition is expected, near 'c'.` (4145); SQLQuack's parser refuses it (`An expression of non-boolean type specified in a context where a condition is expected.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t WITH (TABLOCK, INDEX(myindex))",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a table hint list opaque (gap `table_hint`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT Employee_ID, Department_ID FROM @MyTableVar",
"formatted": null,
"reason": "SQL Server rejects it: `Must declare the table variable \"@MyTableVar\".` (1087); SQLQuack's parser keeps a table variable source opaque (gap `table_variable`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT x FROM @MyTableVar AS m JOIN Employee ON m.EmployeeID = Employee.EmployeeID",
"formatted": null,
"reason": "SQL Server rejects it: `Must declare the table variable \"@MyTableVar\".` (1087); SQLQuack's parser keeps a table variable source opaque (gap `table_variable`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t FOR XML PATH, BINARY BASE64, ELEMENTS XSINIL",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR XML, FOR JSON or FOR BROWSE clause opaque (gap `for_xml_json`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT (SELECT TOP 5 a, b FROM t ORDER BY b DESC FOR JSON PATH) AS j FROM x",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR XML, FOR JSON or FOR BROWSE clause opaque (gap `for_xml_json`) on FOR JSON in a scalar subquery, a parser false reject; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT j FROM (SELECT a AS j FROM t FOR JSON PATH) AS x",
"formatted": null,
"reason": "SQL Server rejects it at binding: `Invalid column name 'j'.` (207, then 8155), as a FOR JSON derived table needs a column list; SQLQuack's parser keeps a FOR XML, FOR JSON or FOR BROWSE clause opaque (gap `for_xml_json`), even with one; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t FOR JSON PATH, ROOT('Root'), INCLUDE_NULL_VALUES",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR XML, FOR JSON or FOR BROWSE clause opaque (gap `for_xml_json`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM t FOR BROWSE",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR XML, FOR JSON or FOR BROWSE clause opaque (gap `for_xml_json`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT TOP 10 PERCENT",
Expand All @@ -321,53 +244,25 @@
"reason": "SQL Server rejects it: `Incorrect syntax near 'TIES'.` (102); SQLQuack's parser refuses it (`Incorrect syntax near the end of the input.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME AS OF 'foo'",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME AS OF 'foo' AS alias",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME FROM c TO d",
"formatted": null,
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`); SQLClean formatted it",
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser refuses it (`Incorrect syntax near 'c'.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME BETWEEN c AND d",
"formatted": null,
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`); SQLClean formatted it",
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser refuses it (`Incorrect syntax near 'c'.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME CONTAINED IN (c, d)",
"formatted": null,
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT [x] FROM [a].[b] FOR SYSTEM_TIME ALL AS alias",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a FOR SYSTEM_TIME clause opaque (gap `system_time`), so the formatter refuses rather than guess; SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT x FROM a INNER LOOP JOIN b ON b.id = a.id",
"formatted": null,
"reason": "SQL Server accepts it; SQLQuack's parser keeps a join hint opaque (gap `join_hint`), so the formatter refuses rather than guess; SQLClean formatted it",
"reason": "SQL Server rejects it: `Incorrect syntax near 'c'.` (102); SQLQuack's parser refuses it (`Incorrect syntax near 'c'.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
Expand All @@ -377,13 +272,6 @@
"reason": "SQL Server rejects it: `Incorrect syntax near the keyword 'schema'.` (156); SQLQuack's parser refuses it (`Incorrect syntax near 'schema'.`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "tsql",
"sql": "SELECT * FROM @x",
"formatted": null,
"reason": "SQL Server rejects it: `Must declare the table variable \"@x\".` (1087); SQLQuack's parser keeps a table variable source opaque (gap `table_variable`); SQLClean formatted it",
"receipt": "crates/sqlquack-format/src/format/tests/fixtures/sqlserver_receipts.jsonl"
},
{
"dialect": "bigquery",
"sql": "SELECT * FROM x.*",
Expand Down
4 changes: 2 additions & 2 deletions crates/sqlclean/src/sql_lint/tests/test_format_corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ fn given_dialect_corpus_when_formatting_then_output_layout_and_refusals_are_stab
test_types::FormatCorpusTestCase {
description: "T-SQL identity corpus",
dialect: "tsql",
expected_formatted: 52,
expected_refused: 23,
expected_formatted: 68,
expected_refused: 7,
},
];
let corpus: Vec<Value> =
Expand Down
Loading