feat: Parse special keywords as functions (current_user, user, etc) (#561)

* feat: Parse special keywors as functions (current_user, user, etc)

* explain special field
This commit is contained in:
Dmitry Patsura 2022-08-11 15:30:06 +03:00 committed by GitHub
parent b6e36ad760
commit 54a29e872d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 111 additions and 17 deletions

View file

@ -421,6 +421,20 @@ impl<'a> Parser<'a> {
self.prev_token();
Ok(Expr::Value(self.parse_value()?))
}
Keyword::CURRENT_CATALOG
| Keyword::CURRENT_USER
| Keyword::SESSION_USER
| Keyword::USER
if dialect_of!(self is PostgreSqlDialect | GenericDialect) =>
{
Ok(Expr::Function(Function {
name: ObjectName(vec![w.to_ident()]),
args: vec![],
over: None,
distinct: false,
special: true,
}))
}
Keyword::CURRENT_TIMESTAMP | Keyword::CURRENT_TIME | Keyword::CURRENT_DATE => {
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
}
@ -598,6 +612,7 @@ impl<'a> Parser<'a> {
args,
over,
distinct,
special: false,
}))
}
@ -612,6 +627,7 @@ impl<'a> Parser<'a> {
args,
over: None,
distinct: false,
special: false,
}))
}