File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -1397,6 +1397,16 @@ impl<'a> Parser<'a> {
13971397
13981398 expr = self.parse_compound_expr(expr, vec![])?;
13991399
1400+ // Parse an optional collation cast operator following `expr`.
1401+ //
1402+ // For example (MSSQL): t1.a COLLATE Latin1_General_CI_AS
1403+ if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
1404+ expr = Expr::Collate {
1405+ expr: Box::new(expr),
1406+ collation: self.parse_object_name(false)?,
1407+ };
1408+ }
1409+
14001410 debug!("prefix: {expr:?}");
14011411 loop {
14021412 let next_precedence = self.get_next_precedence()?;
@@ -1962,14 +1972,7 @@ impl<'a> Parser<'a> {
19621972 _ => self.expected_at("an expression", next_token_index),
19631973 }?;
19641974
1965- if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
1966- Ok(Expr::Collate {
1967- expr: Box::new(expr),
1968- collation: self.parse_object_name(false)?,
1969- })
1970- } else {
1971- Ok(expr)
1972- }
1975+ Ok(expr)
19731976 }
19741977
19751978 fn parse_geometric_type(&mut self, kind: GeometricTypeKind) -> Result<Expr, ParserError> {
Original file line number Diff line number Diff line change @@ -2875,6 +2875,11 @@ fn parse_mssql_update_with_output_into() {
28752875 ) ;
28762876}
28772877
2878+ #[ test]
2879+ fn test_collate_on_compound_identifier ( ) {
2880+ ms_and_generic ( ) . verified_stmt ( "SELECT t1.a COLLATE Latin1_General_CI_AS FROM t1" ) ;
2881+ }
2882+
28782883#[ test]
28792884fn parse_mssql_money_constants ( ) {
28802885 ms ( ) . verified_only_select ( "SELECT CEILING($123.45)" ) ;
You can’t perform that action at this time.
0 commit comments