DBZ-4208 Add test case for sequence-based defaults
This commit is contained in:
parent
343318b5d4
commit
3fd784c51d
@ -26,6 +26,7 @@
|
||||
import io.debezium.data.Envelope;
|
||||
import io.debezium.doc.FixFor;
|
||||
import io.debezium.embedded.AbstractConnectorTest;
|
||||
import io.debezium.junit.logging.LogInterceptor;
|
||||
import io.debezium.time.MicroDuration;
|
||||
import io.debezium.util.Testing;
|
||||
|
||||
@ -46,12 +47,16 @@ public void before() throws Exception {
|
||||
initializeConnectorTestFramework();
|
||||
Testing.Files.delete(TestHelper.DB_HISTORY_PATH);
|
||||
TestHelper.dropTable(connection, "default_value_test");
|
||||
TestHelper.dropSequence(connection, "debezium_seq");
|
||||
|
||||
connection.execute("CREATE SEQUENCE debezium_seq MINVALUE 1 MAXVALUE 999999999 INCREMENT BY 1 START WITH 1");
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws Exception {
|
||||
if (connection != null && connection.isConnected()) {
|
||||
TestHelper.dropTable(connection, "default_value_test");
|
||||
TestHelper.dropSequence(connection, "debezium_seq");
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
@ -269,6 +274,22 @@ public void shouldHandleIntervalDefaultTypes() throws Exception {
|
||||
shouldHandleDefaultValuesCommon(columnDefinitions);
|
||||
}
|
||||
|
||||
@Test
|
||||
@FixFor("DBZ-4208")
|
||||
public void shouldHandleDefaultValueFromSequencesAsNoDefault() throws Exception {
|
||||
// Used to track the number of default value parser exceptions
|
||||
LogInterceptor logInterceptor = new LogInterceptor();
|
||||
|
||||
List<ColumnDefinition> columnDefinitions = Arrays.asList(
|
||||
new ColumnDefinition("val_id", "number(18,0)",
|
||||
"debezium_seq.nextval", "debezium_seq.nextval",
|
||||
BigDecimal.valueOf(1L), BigDecimal.valueOf(2L),
|
||||
AssertionType.FIELD_NO_DEFAULT));
|
||||
|
||||
shouldHandleDefaultValuesCommon(columnDefinitions);
|
||||
assertThat(logInterceptor.countOccurrences("Cannot parse column default value")).isEqualTo(4);
|
||||
}
|
||||
|
||||
private long getOracleIntervalYearMonth(int years, int month) {
|
||||
return MicroDuration.durationMicros(years, month, 0, 0, 0, 0, MicroDuration.DAYS_PER_MONTH_AVG);
|
||||
}
|
||||
|
@ -324,6 +324,17 @@ public static void dropTables(OracleConnection connection, String... tables) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void dropSequence(OracleConnection connection, String sequence) {
|
||||
try {
|
||||
connection.execute("DROP SEQUENCE " + sequence);
|
||||
}
|
||||
catch (SQLException e) {
|
||||
if (!e.getMessage().contains("ORA-02289") || 2289 != e.getErrorCode()) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a given table to be streamed by Oracle.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user