Skip to content

Commit bd88613

Browse files
author
Roman Borschel
committed
Merge branch 'collate-after-compound-expr' into cluvio
2 parents 25b2ad4 + c7d8c33 commit bd88613

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/parser/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,13 @@ impl<'a> Parser<'a> {
13941394

13951395
expr = self.parse_compound_expr(expr, vec![])?;
13961396

1397+
if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
1398+
expr = Expr::Collate {
1399+
expr: Box::new(expr),
1400+
collation: self.parse_object_name(false)?,
1401+
};
1402+
}
1403+
13971404
debug!("prefix: {expr:?}");
13981405
loop {
13991406
let next_precedence = self.get_next_precedence()?;
@@ -1935,14 +1942,7 @@ impl<'a> Parser<'a> {
19351942
_ => self.expected_at("an expression", next_token_index),
19361943
}?;
19371944

1938-
if !self.in_column_definition_state() && self.parse_keyword(Keyword::COLLATE) {
1939-
Ok(Expr::Collate {
1940-
expr: Box::new(expr),
1941-
collation: self.parse_object_name(false)?,
1942-
})
1943-
} else {
1944-
Ok(expr)
1945-
}
1945+
Ok(expr)
19461946
}
19471947

19481948
fn parse_geometric_type(&mut self, kind: GeometricTypeKind) -> Result<Expr, ParserError> {

tests/sqlparser_mssql.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,3 +2874,8 @@ fn parse_mssql_update_with_output_into() {
28742874
"UPDATE employees SET salary = salary * 1.1 OUTPUT INSERTED.id, DELETED.salary, INSERTED.salary INTO @changes WHERE department = 'Engineering'",
28752875
);
28762876
}
2877+
2878+
#[test]
2879+
fn test_collate_on_compound_identifier() {
2880+
tsql().verified_stmt("SELECT t1.a COLLATE Latin1_General_CI_AS FROM t1");
2881+
}

0 commit comments

Comments
 (0)