[fix] Adding space after -- for SQL comments (#7897)

This commit is contained in:
John Bodley
2019-07-18 13:17:26 -07:00
committed by GitHub
parent fce11665f4
commit ccedbea506
2 changed files with 5 additions and 5 deletions

View File

@@ -262,14 +262,14 @@ class SqlaTableModelTestCase(SupersetTestCase):
extras={},
)
sql = tbl.get_query_str(query_obj)
self.assertNotIn("--COMMENT", sql)
self.assertNotIn("-- COMMENT", sql)
def mutator(*args):
return "--COMMENT\n" + args[0]
return "-- COMMENT\n" + args[0]
app.config["SQL_QUERY_MUTATOR"] = mutator
sql = tbl.get_query_str(query_obj)
self.assertIn("--COMMENT", sql)
self.assertIn("-- COMMENT", sql)
app.config["SQL_QUERY_MUTATOR"] = None

View File

@@ -449,13 +449,13 @@ 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"
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"
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")