Skip to content

Commit 002f37d

Browse files
committed
Fix incorrect splitting with double quotes and a new line
1 parent 9cf45eb commit 002f37d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

sqlparse/keywords.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def is_keyword(value):
6464
(r'-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer),
6565
(r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single),
6666
# not a real string literal in ANSI SQL:
67+
(r'"(""|\\\\|\\"|[^"])*"', tokens.String.Symbol),
6768
(r'(""|".*?[^\\]")', tokens.String.Symbol),
6869
# sqlite names can be escaped with [square brackets]. left bracket
6970
# cannot be preceded by word character or a right bracket --

tests/test_split.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,13 @@ def test_split_simple():
139139
assert len(stmts) == 2
140140
assert stmts[0] == 'select * from foo;'
141141
assert stmts[1] == 'select * from bar;'
142+
143+
144+
def test_split_quotes_with_new_line():
145+
stmts = sqlparse.split('select "foo\nbar"')
146+
assert len(stmts) == 1
147+
assert stmts[0] == 'select "foo\nbar"'
148+
149+
stmts = sqlparse.split("select 'foo\n\bar'")
150+
assert len(stmts) == 1
151+
assert stmts[0] == "select 'foo\n\bar'"

0 commit comments

Comments
 (0)