Skip to content

Commit 98609ac

Browse files
committed
Add check for single-line quoted strings which are SQL statements
1 parent 0c7eb2a commit 98609ac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

grammars/python.cson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@
15361536
]
15371537
}
15381538
{
1539-
'begin': '(\')(?=\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER))'
1539+
'begin': '(\')(?=\\s*(SELECT|INSERT|UPDATE|DELETE|CREATE|REPLACE|ALTER|WITH))'
15401540
'beginCaptures':
15411541
'1':
15421542
'name': 'punctuation.definition.string.begin.python'

spec/python-spec.coffee

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,11 @@ describe "Python grammar", ->
327327
expect(tokens[7][0]).toEqual value: 'SELECT COUNT(*)', scopes: ['source.python', scope]
328328
expect(tokens[8][0]).toEqual value: 'FROM example_cte', scopes: ['source.python', scope]
329329
expect(tokens[9][0]).toEqual value: delim, scopes: ['source.python', scope, 'punctuation.definition.string.end.python']
330+
331+
it "tokenizes SQL inline highlighting on single line with a CTE", ->
332+
333+
tokens = grammar.tokenizeLines('WITH example_cte AS (SELECT bar FROM foo) SELECT COUNT(*) FROM example_cte')
334+
335+
expect(tokens[0][0]).toEqual value: '\'', scopes: ['source.python', scope, 'punctuation.definition.string.begin.python']
336+
expect(tokens[1][0]).toEqual value: 'WITH example_cte AS (SELECT bar FROM foo) SELECT COUNT(*) FROM example_cte', scopes: ['source.python', scope]
337+
expect(tokens[2][0]).toEqual value: '\'', scopes: ['source.python', scope, 'punctuation.definition.string.end.python']

0 commit comments

Comments
 (0)