#comments without space after # ,get_type() is UNKNOWN
HI!
sql = """#comments
select * from test_user WHERE id= 1;"""
sql1 = sqlparse.parse(sql)
t = sqlparse.sql.Statement(sql1[0].tokens)
sql2 = sqlparse.format(sql,strip_comments=True)
print t.get_type()
print sql2
sqltest = """# comments
select * from test_user WHERE id= 1;"""
sqltest1 = sqlparse.parse(sqltest)
t1 = sqlparse.sql.Statement(sqltest1[0].tokens)
sqltest2 = sqlparse.format(sqltest,strip_comments=True)
print t1.get_type()
print sqltest2
output
UNKNOWN
#comments
select * from test_user WHERE id= 1;
----------
SELECT
select * from test_user WHERE id= 1;
MySQL support #comments without space after # sqlparse cannt support #comments without space after #?
Do we have any update on this issue, comments are not stripped and the query does not split as well when #<not_space comments> are encountered
example:
import sqlparse
sql = """#comments1
select id
from test_user;
select id
from test_user2; """
query_list = sqlparse.split(sql)
print(query_list)
['#comments1\nselect id\nfrom test_user;\nselect id\nfrom test_user2;']
import sqlparse
sql = """# comments1
select id
from test_user;
select id
from test_user2; """
query_list = sqlparse.split(sql)
print(query_list)
result:
['# comments1\nselect id\nfrom test_user;', 'select id\nfrom test_user2;']
No space after # and a backtick is not working in harmony to split the sql queries
See #596 as well