File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
src/net/sf/jsqlparser/parser
testsrc/net/sf/jsqlparser/test/insert Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
194194| <K_OUTER:"OUTER">
195195| <K_ORDER:"ORDER">
196196| <K_RIGHT:"RIGHT">
197+ | <K_VALUE:"VALUE">
197198| <K_DELETE:"DELETE">
198199| <K_CREATE:"CREATE">
199200| <K_SELECT:"SELECT">
@@ -326,7 +327,7 @@ Replace Replace():
326327 [LOOKAHEAD(2) "(" tableColumn=Column() { columns.add(tableColumn); } ("," tableColumn=Column() { columns.add(tableColumn); } )* ")" ]
327328
328329 (
329- <K_VALUES> "(" exp=PrimaryExpression() { expList.add(exp); }
330+ [ <K_VALUES> | <K_VALUE>] "(" exp=PrimaryExpression() { expList.add(exp); }
330331 ("," exp=PrimaryExpression() { expList.add(exp); } )* ")" { itemsList = new ExpressionList(expList); }
331332
332333 |
@@ -365,7 +366,7 @@ Insert Insert():
365366 [LOOKAHEAD(2) "(" tableColumn=Column() { columns.add(tableColumn); } ("," tableColumn=Column() { columns.add(tableColumn); } )* ")" ]
366367
367368 (
368- <K_VALUES> "(" exp=SimpleExpression() { primaryExpList.add(exp); }
369+ [ <K_VALUES> | <K_VALUE>] "(" exp=SimpleExpression() { primaryExpList.add(exp); }
369370 ("," exp=SimpleExpression() { primaryExpList.add(exp); } )* ")" { itemsList = new ExpressionList(primaryExpList); }
370371
371372 |
Original file line number Diff line number Diff line change @@ -49,6 +49,17 @@ public void testRegularInsert() throws JSQLParserException {
4949
5050 }
5151
52+ public void testInsertWithKeywordValue () throws JSQLParserException {
53+ String statement = "INSERT INTO mytable (col1) VALUE ('val1')" ;
54+ Insert insert = (Insert ) parserManager .parse (new StringReader (statement ));
55+ assertEquals ("mytable" , insert .getTable ().getName ());
56+ assertEquals (1 , insert .getColumns ().size ());
57+ assertEquals ("col1" , ((Column ) insert .getColumns ().get (0 )).getColumnName ());
58+ assertEquals ("val1" ,
59+ ((StringValue ) ((ExpressionList ) insert .getItemsList ()).getExpressions ().get (0 )).getValue ());
60+ assertEquals ("INSERT INTO mytable (col1) VALUES ('val1')" , insert .toString ());
61+ }
62+
5263 public void testInsertFromSelect () throws JSQLParserException {
5364 String statement = "INSERT INTO mytable (col1, col2, col3) SELECT * FROM mytable2" ;
5465 Insert insert = (Insert ) parserManager .parse (new StringReader (statement ));
You can’t perform that action at this time.
0 commit comments