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 @@ -3018,13 +3018,20 @@ JsonExpression JsonExpression() : {
3018
3018
3019
3019
IntervalExpression IntervalExpression() : {
3020
3020
IntervalExpression interval;
3021
+ Column col;
3021
3022
Token token;
3022
3023
boolean signed = false;
3023
3024
}
3024
3025
{
3025
3026
{ interval = new IntervalExpression(); }
3026
- <K_INTERVAL> ["-" {signed=true;}] (token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
3027
- { interval.setParameter((signed?"-":"") + token.image); }
3027
+ <K_INTERVAL> ["-" {signed=true;}]
3028
+ (
3029
+ ((token=<S_LONG> | token=<S_DOUBLE> | token=<S_CHAR_LITERAL> )
3030
+ { interval.setParameter((signed?"-":"") + token.image); })
3031
+ |
3032
+ (col=Column()
3033
+ { interval.setExpression(col); })
3034
+ )
3028
3035
[ LOOKAHEAD(2) (token = <S_IDENTIFIER> | token = <K_DATE_LITERAL>) { interval.setIntervalType(token.image); } ]
3029
3036
{
3030
3037
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