|
10 | 10 | package net.sf.jsqlparser.statement.update;
|
11 | 11 |
|
12 | 12 | import net.sf.jsqlparser.JSQLParserException;
|
| 13 | +import net.sf.jsqlparser.expression.BooleanValue; |
13 | 14 | import net.sf.jsqlparser.expression.DoubleValue;
|
14 | 15 | import net.sf.jsqlparser.expression.JdbcParameter;
|
15 | 16 | import net.sf.jsqlparser.expression.LongValue;
|
|
36 | 37 | import static net.sf.jsqlparser.test.TestUtils.assertUpdateMysqlHintExists;
|
37 | 38 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
38 | 39 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
| 40 | +import static org.junit.jupiter.api.Assertions.assertInstanceOf; |
39 | 41 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
40 | 42 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
41 | 43 |
|
@@ -550,4 +552,18 @@ public void testPreferringClause(String sqlStr) throws JSQLParserException {
|
550 | 552 | assertSqlCanBeParsedAndDeparsed(sqlStr);
|
551 | 553 | }
|
552 | 554 |
|
| 555 | + @Test |
| 556 | + public void testUpdateWithBoolean() throws JSQLParserException { |
| 557 | + String statement = "UPDATE mytable set col1='as', col2=true Where o >= 3"; |
| 558 | + Update update = (Update) PARSER_MANAGER.parse(new StringReader(statement)); |
| 559 | + assertEquals("mytable", update.getTable().toString()); |
| 560 | + assertEquals(2, update.getUpdateSets().size()); |
| 561 | + assertEquals("col1", update.getUpdateSets().get(0).getColumns().get(0).getColumnName()); |
| 562 | + assertEquals("col2", update.getUpdateSets().get(1).getColumns().get(0).getColumnName()); |
| 563 | + assertEquals("as", |
| 564 | + ((StringValue) update.getUpdateSets().get(0).getValues().get(0)).getValue()); |
| 565 | + assertInstanceOf(BooleanValue.class, update.getUpdateSets().get(1).getValues().get(0)); |
| 566 | + assertTrue(((BooleanValue) update.getUpdateSets().get(1).getValues().get(0)).getValue()); |
| 567 | + assertInstanceOf(GreaterThanEquals.class, update.getWhere()); |
| 568 | + } |
553 | 569 | }
|
0 commit comments