File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -704,8 +704,9 @@ impl<'a> Tokenizer<'a> {
704704 }
705705 Ok ( Some ( Token :: Whitespace ( Whitespace :: Newline ) ) )
706706 }
707- // BigQuery uses b or B for byte string literal
708- b @ 'B' | b @ 'b' if dialect_of ! ( self is BigQueryDialect | GenericDialect ) => {
707+ // BigQuery and MySQL use b or B for byte string literal, Postgres for bit strings
708+ b @ 'B' | b @ 'b' if dialect_of ! ( self is BigQueryDialect | PostgreSqlDialect | MySqlDialect | GenericDialect ) =>
709+ {
709710 chars. next ( ) ; // consume
710711 match chars. peek ( ) {
711712 Some ( '\'' ) => {
Original file line number Diff line number Diff line change @@ -2960,3 +2960,14 @@ fn parse_logical_xor() {
29602960 select. projection[ 3 ]
29612961 ) ;
29622962}
2963+
2964+ #[ test]
2965+ fn parse_bitstring_literal ( ) {
2966+ let select = mysql_and_generic ( ) . verified_only_select ( "SELECT B'111'" ) ;
2967+ assert_eq ! (
2968+ select. projection,
2969+ vec![ SelectItem :: UnnamedExpr ( Expr :: Value (
2970+ Value :: SingleQuotedByteStringLiteral ( "111" . to_string( ) )
2971+ ) ) ]
2972+ ) ;
2973+ }
Original file line number Diff line number Diff line change @@ -5098,3 +5098,14 @@ fn parse_create_type_as_enum() {
50985098 _ => unreachable ! ( ) ,
50995099 }
51005100}
5101+
5102+ #[ test]
5103+ fn parse_bitstring_literal ( ) {
5104+ let select = pg_and_generic ( ) . verified_only_select ( "SELECT B'111'" ) ;
5105+ assert_eq ! (
5106+ select. projection,
5107+ vec![ SelectItem :: UnnamedExpr ( Expr :: Value (
5108+ Value :: SingleQuotedByteStringLiteral ( "111" . to_string( ) )
5109+ ) ) ]
5110+ ) ;
5111+ }
You can’t perform that action at this time.
0 commit comments