Trim query before parsing (#6703)

* Ignore empty lines

* Fix unit tests

* Use stripped

* Fix another unit test
This commit is contained in:
Beto Dealmeida 2019-01-17 09:16:35 -08:00 committed by GitHub
parent 9c7b98a27a
commit 99d6dc07d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View File

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

View File

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