feat: Support LOCALTIME and LOCALTIMESTAMP time functions (#592)

This commit is contained in:
Alex Qyoun-ae 2022-08-30 20:15:39 +04:00 committed by GitHub
parent bccd63ea07
commit 0bb49cea99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 1 deletions

View file

@ -438,7 +438,11 @@ impl<'a> Parser<'a> {
special: true,
}))
}
Keyword::CURRENT_TIMESTAMP | Keyword::CURRENT_TIME | Keyword::CURRENT_DATE => {
Keyword::CURRENT_TIMESTAMP
| Keyword::CURRENT_TIME
| Keyword::CURRENT_DATE
| Keyword::LOCALTIME
| Keyword::LOCALTIMESTAMP => {
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
}
Keyword::CASE => self.parse_case_expr(),

View file

@ -5353,6 +5353,38 @@ fn parse_time_functions() {
// Validating Parenthesis
one_statement_parses_to("SELECT CURRENT_DATE", sql);
let sql = "SELECT LOCALTIME()";
let select = verified_only_select(sql);
assert_eq!(
&Expr::Function(Function {
name: ObjectName(vec![Ident::new("LOCALTIME")]),
args: vec![],
over: None,
distinct: false,
special: false,
}),
expr_from_projection(&select.projection[0])
);
// Validating Parenthesis
one_statement_parses_to("SELECT LOCALTIME", sql);
let sql = "SELECT LOCALTIMESTAMP()";
let select = verified_only_select(sql);
assert_eq!(
&Expr::Function(Function {
name: ObjectName(vec![Ident::new("LOCALTIMESTAMP")]),
args: vec![],
over: None,
distinct: false,
special: false,
}),
expr_from_projection(&select.projection[0])
);
// Validating Parenthesis
one_statement_parses_to("SELECT LOCALTIMESTAMP", sql);
}
#[test]