|
10 | 10 | package net.sf.jsqlparser.statement.select; |
11 | 11 |
|
12 | 12 | import net.sf.jsqlparser.JSQLParserException; |
| 13 | +import net.sf.jsqlparser.parser.CCJSqlParserUtil; |
13 | 14 | import net.sf.jsqlparser.test.TestUtils; |
14 | 15 | import org.junit.jupiter.api.Test; |
| 16 | +import org.junit.jupiter.params.ParameterizedTest; |
| 17 | +import org.junit.jupiter.params.provider.ValueSource; |
| 18 | + |
| 19 | +import java.util.Locale; |
| 20 | + |
| 21 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
15 | 22 |
|
16 | 23 | public class SQLiteTest { |
17 | 24 | @Test |
18 | 25 | void testInsertOrReplaceUpsert() throws JSQLParserException { |
19 | 26 | String sqlString = "INSERT OR REPLACE INTO kjobLocks VALUES (?, ?, ?)"; |
20 | 27 | TestUtils.assertSqlCanBeParsedAndDeparsed(sqlString, true); |
21 | 28 | } |
| 29 | + |
| 30 | + @ParameterizedTest |
| 31 | + @ValueSource(strings = {"ABORT", "FAIL", "IGNORE", "REPLACE", "ROLLBACK"}) |
| 32 | + void testInsertOrConflictAlgorithm(String algorithm) throws JSQLParserException { |
| 33 | + TestUtils.assertSqlCanBeParsedAndDeparsed( |
| 34 | + "INSERT OR " + algorithm + " INTO t (a, b) VALUES (1, 2)", true); |
| 35 | + TestUtils.assertSqlCanBeParsedAndDeparsed( |
| 36 | + "insert or " + algorithm.toLowerCase(Locale.ROOT) + " into t select * from s", true); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + void testInsertOrUnknownAlgorithm() { |
| 41 | + assertThrows(JSQLParserException.class, |
| 42 | + () -> CCJSqlParserUtil.parse("INSERT OR NOTHING INTO t VALUES (1)")); |
| 43 | + } |
22 | 44 | } |
0 commit comments