Skip to content

Commit 3d230e7

Browse files
authored
Also highlight unchecked variants of the sqlx query methods (#6256)
1 parent 3907358 commit 3d230e7

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

runtime/queries/rust/injections.scm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,30 @@
5151
[(string_literal) (raw_string_literal)] @injection.content
5252
)
5353
(#set! injection.language "sql"))
54+
55+
; Highlight SQL in `sqlx::query_unchecked!()`
56+
(macro_invocation
57+
macro: (scoped_identifier
58+
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
59+
name: (identifier) @_query_as (#eq? @_query_as "query_unchecked"))
60+
(token_tree
61+
; Only the first argument is SQL
62+
.
63+
[(string_literal) (raw_string_literal)] @injection.content
64+
)
65+
(#set! injection.language "sql"))
66+
67+
; Highlight SQL in `sqlx::query_as_unchecked!()`
68+
(macro_invocation
69+
macro: (scoped_identifier
70+
path: (identifier) @_sqlx (#eq? @_sqlx "sqlx")
71+
name: (identifier) @_query_as (#eq? @_query_as "query_as_unchecked"))
72+
(token_tree
73+
; Only the second argument is SQL
74+
.
75+
; Allow anything as the first argument in case the user has lower case type
76+
; names for some reason
77+
(_)
78+
[(string_literal) (raw_string_literal)] @injection.content
79+
)
80+
(#set! injection.language "sql"))

0 commit comments

Comments
 (0)