Break line before LIMIT statement to prevent trailing comment issue (#7485)

* Break line before LIMIT statement to prevent trailing comment issue

This may not be a perfect solution but it addresses the issue in 7483

closes https://github.com/apache/incubator-superset/issues/7483

* fix tests
This commit is contained in:
Maxime Beauchemin
2019-05-13 00:34:34 -05:00
committed by GitHub
parent 4377328e39
commit d8be0a7dd5
4 changed files with 24 additions and 4 deletions

View File

@@ -431,6 +431,25 @@ class SupersetTestCase(unittest.TestCase):
"""
self.assertEquals({'SalesOrderHeader'}, self.extract_tables(query))
def test_get_query_with_new_limit_comment(self):
sql = 'SELECT * FROM ab_user --SOME COMMENT'
parsed = sql_parse.ParsedQuery(sql)
newsql = parsed.get_query_with_new_limit(1000)
self.assertEquals(newsql, sql + '\nLIMIT 1000')
def test_get_query_with_new_limit_comment_with_limit(self):
sql = 'SELECT * FROM ab_user --SOME COMMENT WITH LIMIT 555'
parsed = sql_parse.ParsedQuery(sql)
newsql = parsed.get_query_with_new_limit(1000)
self.assertEquals(newsql, sql + '\nLIMIT 1000')
def test_get_query_with_new_limit(self):
sql = 'SELECT * FROM ab_user LIMIT 555'
parsed = sql_parse.ParsedQuery(sql)
newsql = parsed.get_query_with_new_limit(1000)
expected = 'SELECT * FROM ab_user LIMIT 1000'
self.assertEquals(newsql, expected)
def test_basic_breakdown_statements(self):
multi_sql = """
SELECT * FROM ab_user;