mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-03 22:08:16 +00:00
Support COLLATE in expressions
Roughly the <character factor> production - https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#character-factor If an expression is followed by the keyword `COLLATE`, it must be followed by the collation name, which is optionally schema-qualified identifier. The `COLLATE` keyword is not a regular binary operator in that it can't be "nested": `foo COLLATE bar COLLATE baz` is not valid. If you prefer to think of it as an operator, you might say it has the highest precedence (judging from the spec), i.e. it binds to the smallest valid expression to the left of it (so in `foo < bar COLLATE c`, the COLLATE is applied first).
This commit is contained in:
parent
e7949d493c
commit
f859c9b80e
3 changed files with 29 additions and 1 deletions
|
@ -209,6 +209,15 @@ fn parse_not() {
|
|||
//TODO: add assertions
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_collate() {
|
||||
let sql = "SELECT name COLLATE \"de_DE\" FROM customer";
|
||||
assert_matches!(
|
||||
only(&all_dialects().verified_only_select(sql).projection),
|
||||
SQLSelectItem::UnnamedExpression(ASTNode::SQLCollate { .. })
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_select_string_predicate() {
|
||||
let sql = "SELECT id, fname, lname FROM customer \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue