File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
main/jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/statement/select Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -2955,13 +2955,20 @@ JsonExpression JsonExpression() : {
2955
2955
2956
2956
IntervalExpression IntervalExpression() : {
2957
2957
IntervalExpression interval;
2958
+ Column col;
2958
2959
Token token;
2959
2960
boolean signed = false;
2960
2961
}
2961
2962
{
2962
2963
{ interval = new IntervalExpression(); }
2963
- <K_INTERVAL> ["-" {signed=true;}] (token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
2964
- { interval.setParameter((signed?"-":"") + token.image); }
2964
+ <K_INTERVAL> ["-" {signed=true;}]
2965
+ (
2966
+ ((token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
2967
+ { interval.setParameter((signed?"-":"") + token.image); })
2968
+ |
2969
+ (col=Column()
2970
+ { interval.setExpression(col); })
2971
+ )
2965
2972
[ LOOKAHEAD(2) (token = <S_IDENTIFIER> | token = <K_DATE_LITERAL>) { interval.setIntervalType(token.image); } ]
2966
2973
{
2967
2974
return interval;
Original file line number Diff line number Diff line change @@ -2177,6 +2177,12 @@ public void testValues6BothVariants() throws JSQLParserException {
2177
2177
assertSqlCanBeParsedAndDeparsed (stmt );
2178
2178
}
2179
2179
2180
+ @ Test
2181
+ public void testIntervalWithColumn () throws JSQLParserException {
2182
+ String stmt = "SELECT DATE_ADD(start_date, INTERVAL duration MINUTE) AS end_datetime FROM appointment" ;
2183
+ assertSqlCanBeParsedAndDeparsed (stmt );
2184
+ }
2185
+
2180
2186
@ Test
2181
2187
public void testInterval1 () throws JSQLParserException {
2182
2188
String stmt = "SELECT 5 + INTERVAL '3 days'" ;
You can’t perform that action at this time.
0 commit comments