Skip to content

Commit ed8820e

Browse files
committed
Initial TiDB Support
1 parent e2bb28b commit ed8820e

File tree

15 files changed

+15577
-1207
lines changed

15 files changed

+15577
-1207
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
It started as a port of a [PHP Library][], but has since considerably diverged.
88

99
It supports various SQL dialects:
10-
GCP BigQuery, IBM DB2, Apache Hive, MariaDB, MySQL, Couchbase N1QL, Oracle PL/SQL, PostgreSQL, Amazon Redshift, SingleStoreDB, Snowflake, Spark, SQL Server Transact-SQL, Trino (and Presto).
10+
GCP BigQuery, IBM DB2, Apache Hive, MariaDB, MySQL, TiDB, Couchbase N1QL, Oracle PL/SQL, PostgreSQL, Amazon Redshift, SingleStoreDB, Snowflake, Spark, SQL Server Transact-SQL, Trino (and Presto).
1111
See [language option docs](docs/language.md) for more details.
1212

1313
It does not support:
@@ -123,7 +123,7 @@ sql-formatter -h
123123

124124
```
125125
usage: sql-formatter [-h] [-o OUTPUT] \
126-
[-l {bigquery,db2,db2i,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,singlestoredb,snowflake,spark,sql,sqlite,transactsql,trino,tsql}] [-c CONFIG] [--version] [FILE]
126+
[-l {bigquery,db2,db2i,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,singlestoredb,snowflake,spark,sql,sqlite,tidb,transactsql,trino,tsql}] [-c CONFIG] [--version] [FILE]
127127
128128
SQL Formatter
129129
@@ -135,7 +135,7 @@ optional arguments:
135135
-o, --output OUTPUT
136136
File to write SQL output (defaults to stdout)
137137
--fix Update the file in-place
138-
-l, --language {bigquery,db2,db2i,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,singlestoredb,snowflake,spark,sql,sqlite,trino,tsql}
138+
-l, --language {bigquery,db2,db2i,hive,mariadb,mysql,n1ql,plsql,postgresql,redshift,singlestoredb,snowflake,spark,sql,sqlite,tidb,trino,tsql}
139139
SQL dialect (defaults to basic sql)
140140
-c, --config CONFIG
141141
Path to config JSON file or json string (will use default configs if unspecified)

docs/dialect.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following dialects can be imported from `"sql-formatter"` module:
2727
- `hive` - [Apache Hive][]
2828
- `mariadb` - [MariaDB][]
2929
- `mysql` - [MySQL][]
30+
- `tidb` - [TiDB][]
3031
- `n1ql` - [Couchbase N1QL][]
3132
- `plsql` - [Oracle PL/SQL][]
3233
- `postgresql` - [PostgreSQL][]
@@ -75,6 +76,7 @@ You likely only want to use this if your other alternative is to fork SQL Format
7576
[apache hive]: https://hive.apache.org/
7677
[mariadb]: https://mariadb.com/
7778
[mysql]: https://www.mysql.com/
79+
[tidb]: https://github.com/pingcap/tidb/
7880
[couchbase n1ql]: http://www.couchbase.com/n1ql
7981
[oracle pl/sql]: http://www.oracle.com/technetwork/database/features/plsql/index.html
8082
[postgresql]: https://www.postgresql.org/

docs/language.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const result = format('SELECT * FROM tbl', { dialect: 'sqlite' });
1919
- `"hive"` - [Apache Hive][]
2020
- `"mariadb"` - [MariaDB][]
2121
- `"mysql"` - [MySQL][]
22+
- `"tidb"` - [TiDB][]
2223
- `"n1ql"` - [Couchbase N1QL][]
2324
- `"plsql"` - [Oracle PL/SQL][]
2425
- `"postgresql"` - [PostgreSQL][]
@@ -52,6 +53,7 @@ See docs for [dialect][] option.
5253
[apache hive]: https://hive.apache.org/
5354
[mariadb]: https://mariadb.com/
5455
[mysql]: https://www.mysql.com/
56+
[tidb]: https://github.com/pingcap/tidb/
5557
[couchbase n1ql]: http://www.couchbase.com/n1ql
5658
[oracle pl/sql]: http://www.oracle.com/technetwork/database/features/plsql/index.html
5759
[postgresql]: https://www.postgresql.org/

docs/params.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ The placeholder types available by default depend on SQL dialect used:
121121
- snowflake - _no support_
122122
- sqlite - `?`, `?1`, `:name`, `@name`, `$name`
123123
- spark - _no support_
124+
- tidb - `?`
124125
- tsql - `@name`, `@"name"`, `@[name]`
125126
- trino - _no support_
126127

0 commit comments

Comments
 (0)