You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by vi...@apache.org on 2019/08/05 14:08:22 UTC
[incubator-superset] branch master updated: Bump sqlparse to 0.3.0
(#7973)
This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new a1261d7 Bump sqlparse to 0.3.0 (#7973)
a1261d7 is described below
commit a1261d7f9ad3ab52f4ad63cdf0d6d99dd5709c0f
Author: Ville Brofeldt <33...@users.noreply.github.com>
AuthorDate: Mon Aug 5 17:08:05 2019 +0300
Bump sqlparse to 0.3.0 (#7973)
* Black
* Bump sqlparse to 0.3.0
* Convert str.format() to f-string
---
requirements.txt | 2 +-
setup.py | 2 +-
superset/sql_parse.py | 14 ++++++--------
3 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/requirements.txt b/requirements.txt
index 38d4922..d1454eb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -75,7 +75,7 @@ simplejson==3.16.0
six==1.12.0 # via bleach, cryptography, flask-jwt-extended, flask-talisman, isodate, jsonschema, pathlib2, polyline, prison, pydruid, pyrsistent, python-dateutil, sqlalchemy-utils, wtforms-json
sqlalchemy-utils==0.34.1
sqlalchemy==1.3.6
-sqlparse==0.2.4
+sqlparse==0.3.0
urllib3==1.25.3 # via requests, selenium
vine==1.3.0 # via amqp, celery
webencodings==0.5.1 # via bleach
diff --git a/setup.py b/setup.py
index 11712c9..a0c02ff 100644
--- a/setup.py
+++ b/setup.py
@@ -98,7 +98,7 @@ setup(
"simplejson>=3.15.0",
"sqlalchemy>=1.3.5,<2.0",
"sqlalchemy-utils>=0.33.2",
- "sqlparse<0.3",
+ "sqlparse>=0.3.0,<0.4",
"wtforms-json",
],
extras_require={
diff --git a/superset/sql_parse.py b/superset/sql_parse.py
index d68ac5e..0619ba1 100644
--- a/superset/sql_parse.py
+++ b/superset/sql_parse.py
@@ -195,21 +195,19 @@ class ParsedQuery(object):
if not self._limit:
return f"{self.stripped()}\nLIMIT {new_limit}"
limit_pos = None
- tokens = self._parsed[0].tokens
+ statement = self._parsed[0]
# Add all items to before_str until there is a limit
- for pos, item in enumerate(tokens):
+ for pos, item in enumerate(statement.tokens):
if item.ttype in Keyword and item.value.lower() == "limit":
limit_pos = pos
break
- limit = tokens[limit_pos + 2]
+ _, limit = statement.token_next(idx=limit_pos)
if limit.ttype == sqlparse.tokens.Literal.Number.Integer:
- tokens[limit_pos + 2].value = new_limit
+ limit.value = new_limit
elif limit.is_group:
- tokens[limit_pos + 2].value = "{}, {}".format(
- next(limit.get_identifiers()), new_limit
- )
+ limit.value = f"{next(limit.get_identifiers())}, {new_limit}"
str_res = ""
- for i in tokens:
+ for i in statement.tokens:
str_res += str(i.value)
return str_res