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 @@ -3017,13 +3017,20 @@ JsonExpression JsonExpression() : {
3017
3017
3018
3018
IntervalExpression IntervalExpression() : {
3019
3019
IntervalExpression interval;
3020
+ Column col;
3020
3021
Token token;
3021
3022
boolean signed = false;
3022
3023
}
3023
3024
{
3024
3025
{ interval = new IntervalExpression(); }
3025
- <K_INTERVAL> ["-" {signed=true;}] (token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
3026
- { interval.setParameter((signed?"-":"") + token.image); }
3026
+ <K_INTERVAL> ["-" {signed=true;}]
3027
+ (
3028
+ ((token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
3029
+ { interval.setParameter((signed?"-":"") + token.image); })
3030
+ |
3031
+ (col=Column()
3032
+ { interval.setExpression(col); })
3033
+ )
3027
3034
[ LOOKAHEAD(2) (token = <S_IDENTIFIER> | token = <K_DATE_LITERAL>) { interval.setIntervalType(token.image); } ]
3028
3035
{
3029
3036
return interval;
Original file line number Diff line number Diff line change @@ -2182,6 +2182,12 @@ public void testValues6BothVariants() throws JSQLParserException {
2182
2182
assertSqlCanBeParsedAndDeparsed (stmt );
2183
2183
}
2184
2184
2185
+ @ Test
2186
+ public void testIntervalWithColumn () throws JSQLParserException {
2187
+ String stmt = "SELECT DATE_ADD(start_date, INTERVAL duration MINUTE) AS end_datetime FROM appointment" ;
2188
+ assertSqlCanBeParsedAndDeparsed (stmt );
2189
+ }
2190
+
2185
2191
@ Test
2186
2192
public void testInterval1 () throws JSQLParserException {
2187
2193
String stmt = "SELECT 5 + INTERVAL '3 days'" ;
You can’t perform that action at this time.
0 commit comments