You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a813f5f
Browse filesBrowse the repository at this point in the historyBrowse files
feat: format BigQuery, PostgreSQL and T-SQL with SQLQuack (#42)
Pin SQLQuack at main 33e43849, whose SQL Server parser reports where each
statement was written and reads procedures, and whose formatter lays out
BigQuery and PostgreSQL.
- bigquery, postgres and postgresql files are formatted; their corpora match
SQLQuack's, with its departures copied.
- tsql, mssql and sqlserver files are formatted; format splits a T-SQL file at
the statements SQL Server's parser reads, so a batch written without
semicolons comes out one statement apart.
- Facts ask whether a dialect parses with SELECT 1, not empty SQL, which the
Databricks parser refuses; Databricks files were failing format.
- The configuration page says which dialects each command reads.
Copy file name to clipboardExpand all lines: crates/sqlclean-cli/skill/references/docs/configuration.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,12 +123,13 @@ SELECT [order id] FROM orders
123
123
error[SQLCLEAN999]: SQL could not be parsed as duckdb: Parse error at line 1, column 17: Expected RBracket, got Var ('id') near [SELECT [order id] FROM orders]
124
124
```
125
125
126
-
SQLClean reads SQL with SQLQuack's parsers. `check` and `fix` read `duckdb`, `generic`, `postgres`,
127
-
`snowflake` and `sqlite` files, and `format` lays out `duckdb` and `snowflake` files; a `generic`,
128
-
`postgres` or `sqlite` file is checked and fixed but left as written by `format`. A file in any
129
-
other dialect, such as `mysql` or `tsql`, is not checked, fixed or formatted: `check` reports it once
130
-
as a warning (in JSON, under `unavailable`), `format` leaves it unchanged with a warning, and it
131
-
never fails a command or counts as a problem.
126
+
SQLClean reads SQL with SQLQuack's parsers. `check` and `fix` read `bigquery`, `databricks`,
127
+
`duckdb`, `generic`, `postgres`, `snowflake` and `sqlite` files, and `format` lays out `bigquery`,
128
+
`duckdb`, `postgres`, `snowflake` and `tsql` files. A `databricks`, `generic` or `sqlite` file is
129
+
checked and fixed but left as written by `format`; a `tsql` file is formatted, by `fix` too, but its
130
+
Rules are not checked yet. A file in any other dialect, such as `mysql`, is not checked, fixed or
131
+
formatted: `check` reports it once as a warning (in JSON, under `unavailable`), `format` leaves it
132
+
unchanged with a warning, and it never fails a command or counts as a problem.
132
133
133
134
```text
134
135
warning: SQL lint is unavailable for the mysql dialect: SQLQuack does not parse it yet
/// Why facts are unavailable for `dialect`: lint's own answer for a dialect SQLQuack does not parse yet.
75
+
/// Where each statement of the batch ends, in characters, as SQL Server's own parser reads it; the whole text when the parser refuses it, so formatting reports why.
let ranges = sqlquack_syntax_sqlserver::parse_strict(sql)
78
+
.map(|parsed| parsed.ranges)
79
+
.unwrap_or_default();
80
+
let ends:Vec<usize> = ranges
81
+
.iter()
82
+
.filter(|range| range.depth == 0)
83
+
.map(|range| sql[..range.end].chars().count())
84
+
.collect();
85
+
match ends.is_empty(){
86
+
true => vec![sql.chars().count()],
87
+
false => ends,
88
+
}
89
+
}
90
+
91
+
/// Why facts are unavailable for `dialect`: lint's own answer for a dialect SQLQuack does not parse yet, asked with a statement every parsed dialect reads, since some refuse empty input.
0 commit comments