mirror of
https://github.com/openwrt/packages.git
synced 2026-04-16 03:12:16 +00:00
python-sqlparse: bump to 0.5.5
Changes since 0.4.4: - v0.5.0: Improved handling of CTEs and window functions - v0.5.0: Better token classification for SQL dialects - v0.5.x: Various bug fixes for edge cases in formatting and statement splitting Also add test.sh to verify formatting, splitting, and parsing. Link: https://github.com/andialbrecht/sqlparse/blob/master/CHANGELOG Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
This commit is contained in:
committed by
Alexandru Ardelean
parent
f2c07b9ba0
commit
2eef8732a3
34
lang/python/python-sqlparse/test.sh
Executable file
34
lang/python/python-sqlparse/test.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$1" = "python3-sqlparse" ] || exit 0
|
||||
|
||||
python3 - << EOF
|
||||
import sys
|
||||
import sqlparse
|
||||
|
||||
if sqlparse.__version__ != "$2":
|
||||
print("Wrong version: " + sqlparse.__version__)
|
||||
sys.exit(1)
|
||||
|
||||
# Format: uppercase keywords
|
||||
formatted = sqlparse.format("select id, name from users where id=1", keyword_case="upper")
|
||||
assert "SELECT" in formatted
|
||||
assert "FROM" in formatted
|
||||
assert "WHERE" in formatted
|
||||
|
||||
# Split multiple statements
|
||||
stmts = sqlparse.split("SELECT 1; SELECT 2; SELECT 3")
|
||||
assert len(stmts) == 3
|
||||
|
||||
# Parse: token inspection
|
||||
parsed = sqlparse.parse("SELECT a, b FROM t")[0]
|
||||
assert parsed.get_type() == "SELECT"
|
||||
|
||||
# Format with indentation
|
||||
sql = "select a,b from t where x=1 and y=2"
|
||||
out = sqlparse.format(sql, reindent=True, keyword_case="upper")
|
||||
assert "SELECT" in out
|
||||
assert "WHERE" in out
|
||||
|
||||
sys.exit(0)
|
||||
EOF
|
||||
Reference in New Issue
Block a user