sqlparse
sqlparse copied to clipboard
Adding support for options when parsing
Addresses #384.
Options added:
-
sql_dialect This option allows the user to select which sql dialect to use when parsing. Prior to this support, all SQL dialects (PGSQL, MYSQL, TSQL, etc.) would share the same list of regex to tokens mapping. This will lead to mismatch token types for certain words.
Example: TransactSQL statement "@@Version" Expected token type: Builtin '@@version' Actual token type: Operator '@@', Identifier 'Version'
Currently supported values are 'TransactSQL'.
-
additional_keywords This option allows the user to supply a list of additional strings to map to Keyword token type when parsing. Currently the list of keywords are hard-coded in the source code. This can create issues for users if they want to use the library against the latest version of their SQL dialect of choice that sqlparse may not have been updated with those new keywords.
Codecov Report
Merging #389 into master will increase coverage by
0.04%
. The diff coverage is100%
.
@@ Coverage Diff @@
## master #389 +/- ##
=========================================
+ Coverage 97.25% 97.3% +0.04%
=========================================
Files 21 21
Lines 1420 1445 +25
=========================================
+ Hits 1381 1406 +25
Misses 39 39
Impacted Files | Coverage Δ | |
---|---|---|
sqlparse/lexer.py | 97.82% <100%> (+0.68%) |
:arrow_up: |
sqlparse/engine/filter_stack.py | 100% <100%> (ø) |
:arrow_up: |
sqlparse/__init__.py | 100% <100%> (ø) |
:arrow_up: |
sqlparse/keywords.py | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 9cf45eb...cdc6691. Read the comment docs.
@andialbrecht, what is the ETA for this PR? I'm working on updating mssql-cli which relies on this update to sqlparse. Please let me know if there is anything I can do to expedite the process. Thank you!
@andialbrecht , thanks for the feedback! I will resume work on this PR in the coming weeks. I'm currently a bit back logged :)
Hi @MrMeemus / @andialbrecht - is there any chance of this PR being progressed? I've been digging into https://github.com/dbcli/pgcli/issues/954 (no completion in pgcli
given a table named events
) and I've tracked the cause down to sqlparse
considering events
as a keyword. However, events
is not a PostgreSQL keyword so it would be great if I could select a Postgres dialect to avoid the misclassification for pgcli
's purposes.
Thanks!