File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,17 @@ impl<'a> Tokenizer<'a> {
417
417
// numbers and period
418
418
'0' ..='9' | '.' => {
419
419
let mut s = peeking_take_while ( chars, |ch| matches ! ( ch, '0' ..='9' ) ) ;
420
+
421
+ // match binary literal that starts with 0x
422
+ if s == "0" && chars. peek ( ) == Some ( & 'x' ) {
423
+ chars. next ( ) ;
424
+ let s2 = peeking_take_while (
425
+ chars,
426
+ |ch| matches ! ( ch, '0' ..='9' | 'A' ..='F' | 'a' ..='f' ) ,
427
+ ) ;
428
+ return Ok ( Some ( Token :: HexStringLiteral ( s2) ) ) ;
429
+ }
430
+
420
431
// match one period
421
432
if let Some ( '.' ) = chars. peek ( ) {
422
433
s. push ( '.' ) ;
Original file line number Diff line number Diff line change @@ -113,6 +113,11 @@ fn parse_mssql_top() {
113
113
let _ = ms_and_generic ( ) . one_statement_parses_to ( sql, "SELECT TOP (5) bar, baz FROM foo" ) ;
114
114
}
115
115
116
+ #[ test]
117
+ fn parse_mssql_bin_literal ( ) {
118
+ let _ = ms_and_generic ( ) . one_statement_parses_to ( "SELECT 0xdeadBEEF" , "SELECT X'deadBEEF'" ) ;
119
+ }
120
+
116
121
fn ms ( ) -> TestedDialects {
117
122
TestedDialects {
118
123
dialects : vec ! [ Box :: new( MsSqlDialect { } ) ] ,
You can’t perform that action at this time.
0 commit comments