Bump sqlparse to 0.3.0 (#7973)

* Black

* Bump sqlparse to 0.3.0

* Convert str.format() to f-string
This commit is contained in:
Ville Brofeldt 2019-08-05 17:08:05 +03:00 committed by GitHub
parent b8ca0783ff
commit a1261d7f9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 10 deletions

View File

@ -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

View File

@ -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={

View File

@ -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