9
9
import static org .hamcrest .CoreMatchers .is ;
10
10
import static org .hamcrest .MatcherAssert .assertThat ;
11
11
import static org .junit .jupiter .api .Assertions .assertFalse ;
12
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
12
13
13
14
public abstract class IndexTests extends AbstractDbTestBase {
14
15
15
16
private static final String CREATE_TABLE_SQL =
16
17
"create table test_table (" +
17
- "id integer null unique " +
18
+ "id integer null unique, " +
19
+ "col1 varchar" +
18
20
")" ;
19
21
22
+ private static final String CREATE_PARTIAL_INDEX_SQL =
23
+ "create unique index partial_idx on test_table(id) where col1 = 'test'" ;
24
+
20
25
public IndexTests (TestDbUrlProvider testDbUrlProvider ) {
21
26
super (testDbUrlProvider );
22
27
}
@@ -39,6 +44,8 @@ public void testRecreateIndexAfterTableChange() throws Exception {
39
44
40
45
// Setup db
41
46
getSourceDbConnection ().createStatement ().execute (CREATE_TABLE_SQL );
47
+ getSourceDbConnection ().createStatement ().execute (CREATE_PARTIAL_INDEX_SQL );
48
+
42
49
sourceToTarget ();
43
50
DummySink dummySink = targetToDummy ();
44
51
Schema schema = dummySink .getTargetSchema ();
@@ -51,6 +58,9 @@ public void testRecreateIndexAfterTableChange() throws Exception {
51
58
52
59
// Verify
53
60
assertFalse (schema .getTable ("test_table" ).getField ("id" ).isNullable ());
54
- assertThat (schema .getTable ("test_table" ).getIndexes ().size (), is (1 ));
61
+ assertThat (schema .getTable ("test_table" ).getIndexes ().size (), is (2 ));
62
+ if (!this .getClass ().getSimpleName ().contains ("Sqlite" )) { // https://github.com/jOOQ/jOOQ/issues/16683
63
+ assertThat (schema .getTable ("test_table" ).getIndex ("partial_idx" ).getWhere (), is ("(((col1)::text = 'test'::text))" ));
64
+ }
55
65
}
56
66
}
0 commit comments