You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/08/02 15:12:35 UTC

[GitHub] [incubator-superset] villebro commented on a change in pull request #7973: Bump sqlparse 030

villebro commented on a change in pull request #7973: Bump sqlparse 030
URL: https://github.com/apache/incubator-superset/pull/7973#discussion_r310176912
 
 

 ##########
 File path: superset/sql_parse.py
 ##########
 @@ -195,21 +195,19 @@ def get_query_with_new_limit(self, new_limit):
         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 = "{}, {}".format(next(limit.get_identifiers()), new_limit)
 
 Review comment:
   Good point 👍 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org