summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorjucasaca <jucasaca@gmail.com>2023-07-28 19:20:14 +0200
committerJulien Nabet <serval2412@yahoo.fr>2023-08-07 23:38:50 +0200
commit42364fbfafaa95773c073cc080142b64ec1786fb (patch)
tree0956c8fa2d70eec243ed5ca697293afc52ee7879 /connectivity
parent616c1da0cc8b345e13bec14b4794e7bab7e1d046 (diff)
tdf#104918 Add Firebird's DATEDIFF syntax to the sql parser
Add one of the Firebird's DATEDIFF syntax to the parser so now it is possible to execute DATEDIFF(unit, datetime, datetime) in the Base Query designer and don't need to execute it in SQL direct anymore Change-Id: I0514542785c47a2a4693cba26de1815c96ee1b9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155027 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/parse/sqlbison.y21
1 files changed, 20 insertions, 1 deletions
diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y
index eef20bd56b4a..fe3b32b79ef6 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -218,7 +218,7 @@ using namespace connectivity;
%type <pParseNode> like_predicate opt_escape test_for_null null_predicate_part_2 in_predicate in_predicate_part_2 character_like_predicate_part_2 other_like_predicate_part_2
%type <pParseNode> all_or_any_predicate any_all_some existence_test subquery quantified_comparison_predicate_part_2
%type <pParseNode> scalar_exp_commalist parameter_ref literal parenthesized_boolean_value_expression
-%type <pParseNode> column_ref data_type column cursor parameter range_variable user /*like_check*/
+%type <pParseNode> column_ref data_type column cursor parameter range_variable user /*like_check*/ datetime_unit
/* new rules at OJ */
%type <pParseNode> derived_column as_clause table_name num_primary term num_value_exp
%type <pParseNode> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec scalar_subquery
@@ -2966,6 +2966,18 @@ non_second_datetime_field:
| SQL_TOKEN_MINUTE
| SQL_TOKEN_MILLISECOND
;
+
+datetime_unit:
+ SQL_TOKEN_YEAR
+ | SQL_TOKEN_MONTH
+ | SQL_TOKEN_WEEK
+ | SQL_TOKEN_DAY
+ | SQL_TOKEN_HOUR
+ | SQL_TOKEN_MINUTE
+ | SQL_TOKEN_SECOND
+ | SQL_TOKEN_MILLISECOND
+ ;
+
start_field:
non_second_datetime_field opt_paren_precision
{
@@ -3097,6 +3109,13 @@ function_args_commalist:
else
YYERROR;
}
+ | datetime_unit ',' function_arg ',' function_arg
+ {
+ $$ = SQL_NEW_COMMALISTRULE;
+ $$->append($1);
+ $$->append($3);
+ $$->append($5);
+ }
;
value_exp: