@@ -26,6 +26,7 @@ enum ParserState {
26
26
MaybeInCComment2 ,
27
27
InCComment ,
28
28
MaybeExitCComment ,
29
+ InQuotedIdentifier ,
29
30
}
30
31
31
32
use self :: ParserState :: * ;
@@ -61,6 +62,7 @@ impl<'a> ParsedNamedParams<'a> {
61
62
b'\'' => state = InStringLiteral ( b'\'' , b'\'' ) ,
62
63
b'"' => state = InStringLiteral ( b'"' , b'"' ) ,
63
64
b'?' => have_positional = true ,
65
+ b'`' => state = InQuotedIdentifier ,
64
66
_ => ( ) ,
65
67
} ,
66
68
InStringLiteral ( separator, prev_char) => match c {
@@ -119,6 +121,11 @@ impl<'a> ParsedNamedParams<'a> {
119
121
b'/' => state = TopLevel ,
120
122
_ => state = InCComment ,
121
123
} ,
124
+ InQuotedIdentifier => {
125
+ if * c == b'`' {
126
+ state = TopLevel
127
+ }
128
+ }
122
129
}
123
130
if rematch {
124
131
match c {
@@ -253,6 +260,17 @@ mod test {
253
260
) ;
254
261
}
255
262
263
+ #[ test]
264
+ fn quoted_identifier ( ) {
265
+ let result = ParsedNamedParams :: parse ( b"INSERT INTO `my:table` VALUES (?)" ) . unwrap ( ) ;
266
+ assert_eq ! ( result. query( ) , b"INSERT INTO `my:table` VALUES (?)" ) ;
267
+ assert ! ( result. params( ) . is_empty( ) ) ;
268
+
269
+ let result = ParsedNamedParams :: parse ( b"INSERT INTO `my:table` VALUES (:foo)" ) . unwrap ( ) ;
270
+ assert_eq ! ( result. query( ) , b"INSERT INTO `my:table` VALUES (?)" ) ;
271
+ assert_eq ! ( result. params( ) , cows!( b"foo" ) ) ;
272
+ }
273
+
256
274
#[ cfg( feature = "nightly" ) ]
257
275
mod bench {
258
276
use super :: * ;
0 commit comments