未验证 提交 99d6dc07 编写于 作者: B Beto Dealmeida 提交者: GitHub

Trim query before parsing (#6703)

* Ignore empty lines

* Fix unit tests

* Use stripped

* Fix another unit test
上级 9c7b98a2
......@@ -34,7 +34,7 @@ class ParsedQuery(object):
self._limit = None
logging.info('Parsing with sqlparse statement {}'.format(self.sql))
self._parsed = sqlparse.parse(self.sql)
self._parsed = sqlparse.parse(self.stripped())
for statement in self._parsed:
self.__extract_from_token(statement)
self._limit = self._extract_limit_from_query(statement)
......
......@@ -196,8 +196,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
FROM
table
LIMIT 99990""",
"""
SELECT
"""SELECT
'LIMIT 777' AS a
, b
FROM
......@@ -214,13 +213,12 @@ class DbEngineSpecsTestCase(SupersetTestCase):
FROM
table
LIMIT 99990 ;""",
"""
SELECT
"""SELECT
'LIMIT 777' AS a
, b
FROM
table
LIMIT 1000 ;""",
LIMIT 1000""",
)
def test_get_datatype(self):
......@@ -238,8 +236,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
FROM
table
LIMIT 99990, 999999""",
"""
SELECT
"""SELECT
'LIMIT 777' AS a
, b
FROM
......@@ -257,8 +254,7 @@ class DbEngineSpecsTestCase(SupersetTestCase):
table
LIMIT 99990
OFFSET 999999""",
"""
SELECT
"""SELECT
'LIMIT 777' AS a
, b
FROM
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册