diff options
| -rw-r--r-- | sqlparse/keywords.py | 1 | ||||
| -rw-r--r-- | tests/test_split.py | 10 |
2 files changed, 11 insertions, 0 deletions
diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py index b5b59e8..bca50ba 100644 --- a/sqlparse/keywords.py +++ b/sqlparse/keywords.py @@ -64,6 +64,7 @@ SQL_REGEX = { (r'-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer), (r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single), # not a real string literal in ANSI SQL: + (r'"(""|\\\\|\\"|[^"])*"', tokens.String.Symbol), (r'(""|".*?[^\\]")', tokens.String.Symbol), # sqlite names can be escaped with [square brackets]. left bracket # cannot be preceded by word character or a right bracket -- diff --git a/tests/test_split.py b/tests/test_split.py index 5d846bf..a93e3d4 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -139,3 +139,13 @@ def test_split_simple(): assert len(stmts) == 2 assert stmts[0] == 'select * from foo;' assert stmts[1] == 'select * from bar;' + + +def test_split_quotes_with_new_line(): + stmts = sqlparse.split('select "foo\nbar"') + assert len(stmts) == 1 + assert stmts[0] == 'select "foo\nbar"' + + stmts = sqlparse.split("select 'foo\n\bar'") + assert len(stmts) == 1 + assert stmts[0] == "select 'foo\n\bar'" |
