@@ -60,7 +60,8 @@ pub enum Token {
6060 DoubleQuotedString ( String ) ,
6161 /// Dollar quoted string: i.e: $$string$$ or $tag_name$string$tag_name$
6262 DollarQuotedString ( DollarQuotedString ) ,
63- /// Byte string literal: i.e: b'string' or B'string'
63+ /// Byte string literal: i.e: b'string' or B'string' (note that some backends, such as
64+ /// PostgreSQL, may treat this syntax as a bit string literal instead, i.e: b'10010101')
6465 SingleQuotedByteStringLiteral ( String ) ,
6566 /// Byte string literal: i.e: b"string" or B"string"
6667 DoubleQuotedByteStringLiteral ( String ) ,
@@ -114,7 +115,7 @@ pub enum Token {
114115 Period ,
115116 /// Colon `:`
116117 Colon ,
117- /// DoubleColon `::` (used for casting in postgresql )
118+ /// DoubleColon `::` (used for casting in PostgreSQL )
118119 DoubleColon ,
119120 /// Assignment `:=` (used for keyword argument in DuckDB macros)
120121 DuckAssignment ,
@@ -152,27 +153,29 @@ pub enum Token {
152153 ShiftLeft ,
153154 /// `>>`, a bitwise shift right operator in PostgreSQL
154155 ShiftRight ,
155- /// '&&' , an overlap operator in PostgreSQL
156+ /// `&&` , an overlap operator in PostgreSQL
156157 Overlap ,
157158 /// Exclamation Mark `!` used for PostgreSQL factorial operator
158159 ExclamationMark ,
159160 /// Double Exclamation Mark `!!` used for PostgreSQL prefix factorial operator
160161 DoubleExclamationMark ,
161162 /// AtSign `@` used for PostgreSQL abs operator
162163 AtSign ,
164+ /// `^@`, a "starts with" string operator in PostgreSQL
165+ CaretAt ,
163166 /// `|/`, a square root math operator in PostgreSQL
164167 PGSquareRoot ,
165168 /// `||/`, a cube root math operator in PostgreSQL
166169 PGCubeRoot ,
167170 /// `?` or `$` , a prepared statement arg placeholder
168171 Placeholder ( String ) ,
169- /// -> , used as a operator to extract json field in PostgreSQL
172+ /// `->` , used as a operator to extract json field in PostgreSQL
170173 Arrow ,
171- /// ->>, used as a operator to extract json field as text in PostgreSQL
174+ /// ` ->>` , used as a operator to extract json field as text in PostgreSQL
172175 LongArrow ,
173- /// #> Extracts JSON sub-object at the specified path
176+ /// `#>`, extracts JSON sub-object at the specified path
174177 HashArrow ,
175- /// #>> Extracts JSON sub-object at the specified path as text
178+ /// ` #>>`, extracts JSON sub-object at the specified path as text
176179 HashLongArrow ,
177180 /// jsonb @> jsonb -> boolean: Test whether left json contains the right json
178181 AtArrow ,
@@ -247,6 +250,7 @@ impl fmt::Display for Token {
247250 Token :: ExclamationMarkTilde => f. write_str ( "!~" ) ,
248251 Token :: ExclamationMarkTildeAsterisk => f. write_str ( "!~*" ) ,
249252 Token :: AtSign => f. write_str ( "@" ) ,
253+ Token :: CaretAt => f. write_str ( "^@" ) ,
250254 Token :: ShiftLeft => f. write_str ( "<<" ) ,
251255 Token :: ShiftRight => f. write_str ( ">>" ) ,
252256 Token :: Overlap => f. write_str ( "&&" ) ,
@@ -940,7 +944,13 @@ impl<'a> Tokenizer<'a> {
940944 _ => Ok ( Some ( Token :: Ampersand ) ) ,
941945 }
942946 }
943- '^' => self . consume_and_return ( chars, Token :: Caret ) ,
947+ '^' => {
948+ chars. next ( ) ; // consume the '^'
949+ match chars. peek ( ) {
950+ Some ( '@' ) => self . consume_and_return ( chars, Token :: CaretAt ) ,
951+ _ => Ok ( Some ( Token :: Caret ) ) ,
952+ }
953+ }
944954 '{' => self . consume_and_return ( chars, Token :: LBrace ) ,
945955 '}' => self . consume_and_return ( chars, Token :: RBrace ) ,
946956 '#' if dialect_of ! ( self is SnowflakeDialect ) => {
0 commit comments