Skip to content

Commit e940876

Browse files
committed
feat: Support LOCALTIME and LOCALTIMESTAMP time functions
1 parent ca8131c commit e940876

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/parser.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,11 @@ impl<'a> Parser<'a> {
435435
special: true,
436436
}))
437437
}
438-
Keyword::CURRENT_TIMESTAMP | Keyword::CURRENT_TIME | Keyword::CURRENT_DATE => {
438+
Keyword::CURRENT_TIMESTAMP
439+
| Keyword::CURRENT_TIME
440+
| Keyword::CURRENT_DATE
441+
| Keyword::LOCALTIME
442+
| Keyword::LOCALTIMESTAMP => {
439443
self.parse_time_functions(ObjectName(vec![w.to_ident()]))
440444
}
441445
Keyword::CASE => self.parse_case_expr(),

tests/sqlparser_common.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4739,6 +4739,38 @@ fn parse_time_functions() {
47394739

47404740
// Validating Parenthesis
47414741
one_statement_parses_to("SELECT CURRENT_DATE", sql);
4742+
4743+
let sql = "SELECT LOCALTIME()";
4744+
let select = verified_only_select(sql);
4745+
assert_eq!(
4746+
&Expr::Function(Function {
4747+
name: ObjectName(vec![Ident::new("LOCALTIME")]),
4748+
args: vec![],
4749+
over: None,
4750+
distinct: false,
4751+
special: false,
4752+
}),
4753+
expr_from_projection(&select.projection[0])
4754+
);
4755+
4756+
// Validating Parenthesis
4757+
one_statement_parses_to("SELECT LOCALTIME", sql);
4758+
4759+
let sql = "SELECT LOCALTIMESTAMP()";
4760+
let select = verified_only_select(sql);
4761+
assert_eq!(
4762+
&Expr::Function(Function {
4763+
name: ObjectName(vec![Ident::new("LOCALTIMESTAMP")]),
4764+
args: vec![],
4765+
over: None,
4766+
distinct: false,
4767+
special: false,
4768+
}),
4769+
expr_from_projection(&select.projection[0])
4770+
);
4771+
4772+
// Validating Parenthesis
4773+
one_statement_parses_to("SELECT LOCALTIMESTAMP", sql);
47424774
}
47434775

47444776
#[test]

0 commit comments

Comments
 (0)