File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,10 @@ def is_keyword(value):
2121
2222SQL_REGEX = {
2323 'root' : [
24- (r'(--|# )\+.*?(\r\n|\r|\n|$)' , tokens .Comment .Single .Hint ),
24+ (r'(--|//| # )\+.*?(\r\n|\r|\n|$)' , tokens .Comment .Single .Hint ),
2525 (r'/\*\+[\s\S]*?\*/' , tokens .Comment .Multiline .Hint ),
2626
27- (r'(--|# ).*?(\r\n|\r|\n|$)' , tokens .Comment .Single ),
27+ (r'(--|//| # ).*?(\r\n|\r|\n|$)' , tokens .Comment .Single ),
2828 (r'/\*[\s\S]*?\*/' , tokens .Comment .Multiline ),
2929
3030 (r'(\r\n|\r|\n)' , tokens .Newline ),
Original file line number Diff line number Diff line change 1+ select * from user;
2+ // select * from host;
3+ select * from user;
4+ select * // foo;
5+ from foo;
Original file line number Diff line number Diff line change @@ -52,6 +52,22 @@ def test_split_dashcomments_eol(s):
5252 assert len (stmts ) == 1
5353
5454
55+ def test_split_slashcomments (load_file ):
56+ sql = load_file ('slashcomment.sql' )
57+ stmts = sqlparse .parse (sql )
58+ assert len (stmts ) == 3
59+ assert '' .join (str (q ) for q in stmts ) == sql
60+
61+
62+ @pytest .mark .parametrize ('s' , ['select foo; // comment\n ' ,
63+ 'select foo; // comment\r ' ,
64+ 'select foo; // comment\r \n ' ,
65+ 'select foo; // comment' ])
66+ def test_split_slashcomments_eol (s ):
67+ stmts = sqlparse .parse (s )
68+ assert len (stmts ) == 1
69+
70+
5571def test_split_begintag (load_file ):
5672 sql = load_file ('begintag.sql' )
5773 stmts = sqlparse .parse (sql )
You can’t perform that action at this time.
0 commit comments