use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseCreateTableWithEnumDefault.
@FixFor("DBZ-160")
@Test
public void shouldParseCreateTableWithEnumDefault() {
String ddl = "CREATE TABLE t ( c1 ENUM('a','b','c') NOT NULL DEFAULT 'b', c2 ENUM('a', 'b', 'c') NOT NULL DEFAULT 'a');";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("c1", "c2");
assertThat(t.primaryKeyColumnNames()).isEmpty();
assertColumn(t, "c1", "ENUM", Types.CHAR, 1, -1, false, false, false);
assertColumn(t, "c2", "ENUM", Types.CHAR, 1, -1, false, false, false);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method parseTableWithNegativeDefault.
@Test
@FixFor("DBZ-429")
public void parseTableWithNegativeDefault() {
String ddl = "CREATE TABLE t (id INT NOT NULL, myvalue INT DEFAULT -10, PRIMARY KEY (`id`));";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("id", "myvalue");
assertThat(t.primaryKeyColumnNames()).hasSize(1);
assertColumn(t, "myvalue", "INT", Types.INTEGER, -1, -1, true, false, false);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method parseDdlForDecAndFixed.
@Test
public void parseDdlForDecAndFixed() {
String ddl = "CREATE TABLE t ( c1 DEC(2) NOT NULL, c2 FIXED(1,0) NOT NULL);";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("c1", "c2");
assertThat(t.primaryKeyColumnNames()).isEmpty();
assertColumn(t, "c1", "DEC", Types.DECIMAL, 2, 0, false, false, false);
assertColumn(t, "c2", "FIXED", Types.DECIMAL, 1, 0, false, false, false);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseCreateTableStatementWithCharacterSetForTable.
@Test
public void shouldParseCreateTableStatementWithCharacterSetForTable() {
String ddl = "CREATE TABLE t ( col1 VARCHAR(25) ) DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; ";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("col1");
assertThat(t.primaryKeyColumnNames()).isEmpty();
assertColumn(t, "col1", "VARCHAR", Types.VARCHAR, 25, -1, true, false, false);
ddl = "CREATE TABLE t2 ( col1 VARCHAR(25) ) DEFAULT CHARSET utf8 DEFAULT COLLATE utf8_general_ci; ";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(2);
Table t2 = tables.forTable(new TableId(null, null, "t2"));
assertThat(t2).isNotNull();
assertThat(t2.columnNames()).containsExactly("col1");
assertThat(t2.primaryKeyColumnNames()).isEmpty();
assertColumn(t2, "col1", "VARCHAR", Types.VARCHAR, 25, -1, true, false, false);
ddl = "CREATE TABLE t3 ( col1 VARCHAR(25) ) CHARACTER SET utf8 COLLATE utf8_general_ci; ";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(3);
Table t3 = tables.forTable(new TableId(null, null, "t3"));
assertThat(t3).isNotNull();
assertThat(t3.columnNames()).containsExactly("col1");
assertThat(t3.primaryKeyColumnNames()).isEmpty();
assertColumn(t3, "col1", "VARCHAR", Types.VARCHAR, 25, -1, true, false, false);
ddl = "CREATE TABLE t4 ( col1 VARCHAR(25) ) CHARSET utf8 COLLATE utf8_general_ci; ";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(4);
Table t4 = tables.forTable(new TableId(null, null, "t4"));
assertThat(t4).isNotNull();
assertThat(t4.columnNames()).containsExactly("col1");
assertThat(t4.primaryKeyColumnNames()).isEmpty();
assertColumn(t4, "col1", "VARCHAR", Types.VARCHAR, 25, -1, true, false, false);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method parseTableWithPageChecksum.
@Test
public void parseTableWithPageChecksum() {
String ddl = "CREATE TABLE t (id INT NOT NULL, PRIMARY KEY (`id`)) PAGE_CHECKSUM=1;" + "ALTER TABLE t PAGE_CHECKSUM=0;";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("id");
assertThat(t.primaryKeyColumnNames()).hasSize(1);
assertColumn(t, "id", "INT", Types.INTEGER, -1, -1, false, false, false);
}
Aggregations