Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 73b3c3a

Browse files
MazterQyoumcheshkov
authored andcommittedSep 2, 2024
feat: Support LOCALTIME and LOCALTIMESTAMP time functions
Can drop this after rebase on commit 0bb49ce "feat: Support LOCALTIME and LOCALTIMESTAMP time functions (apache#592)", first released in 0.23.0
1 parent 8117163 commit 73b3c3a

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
@@ -4932,6 +4932,38 @@ fn parse_time_functions() {
49324932

49334933
// Validating Parenthesis
49344934
one_statement_parses_to("SELECT CURRENT_DATE", sql);
4935+
4936+
let sql = "SELECT LOCALTIME()";
4937+
let select = verified_only_select(sql);
4938+
assert_eq!(
4939+
&Expr::Function(Function {
4940+
name: ObjectName(vec![Ident::new("LOCALTIME")]),
4941+
args: vec![],
4942+
over: None,
4943+
distinct: false,
4944+
special: false,
4945+
}),
4946+
expr_from_projection(&select.projection[0])
4947+
);
4948+
4949+
// Validating Parenthesis
4950+
one_statement_parses_to("SELECT LOCALTIME", sql);
4951+
4952+
let sql = "SELECT LOCALTIMESTAMP()";
4953+
let select = verified_only_select(sql);
4954+
assert_eq!(
4955+
&Expr::Function(Function {
4956+
name: ObjectName(vec![Ident::new("LOCALTIMESTAMP")]),
4957+
args: vec![],
4958+
over: None,
4959+
distinct: false,
4960+
special: false,
4961+
}),
4962+
expr_from_projection(&select.projection[0])
4963+
);
4964+
4965+
// Validating Parenthesis
4966+
one_statement_parses_to("SELECT LOCALTIMESTAMP", sql);
49354967
}
49364968

49374969
#[test]

0 commit comments

Comments
 (0)
Please sign in to comment.