use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseCreateTableStatementWithCollate.
@Test
@FixFor("DBZ-474")
public void shouldParseCreateTableStatementWithCollate() {
String ddl = "CREATE TABLE c1 (pk INT PRIMARY KEY, v1 CHAR(36) NOT NULL COLLATE utf8_unicode_ci);";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table table = tables.forTable(new TableId(null, null, "c1"));
assertThat(table).isNotNull();
assertColumn(table, "v1", "CHAR", Types.CHAR, 36, -1, false, false, false);
Column column = table.columnWithName("v1");
assertThat(column.typeUsesCharset()).isTrue();
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseAlterTableStatementThatAddsCharacterSetForColumns.
@Test
public void shouldParseAlterTableStatementThatAddsCharacterSetForColumns() {
String ddl = "CREATE TABLE t ( col1 VARCHAR(25) ); ";
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, null, true);
ddl = "ALTER TABLE t MODIFY col1 VARCHAR(50) CHARACTER SET greek;";
parser.parse(ddl, tables);
Table t2 = tables.forTable(new TableId(null, null, "t"));
assertThat(t2).isNotNull();
assertThat(t2.columnNames()).containsExactly("col1");
assertThat(t2.primaryKeyColumnNames()).isEmpty();
assertColumn(t2, "col1", "VARCHAR", Types.VARCHAR, 50, "greek", true);
ddl = "ALTER TABLE t MODIFY col1 VARCHAR(75) CHARSET utf8;";
parser.parse(ddl, tables);
Table t3 = tables.forTable(new TableId(null, null, "t"));
assertThat(t3).isNotNull();
assertThat(t3.columnNames()).containsExactly("col1");
assertThat(t3.primaryKeyColumnNames()).isEmpty();
assertColumn(t3, "col1", "VARCHAR", Types.VARCHAR, 75, "utf8", true);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseTimeWithNowDefault.
@Test
@FixFor("DBZ-169")
public void shouldParseTimeWithNowDefault() {
String ddl = "CREATE TABLE t1 ( " + "c1 int primary key auto_increment, " + "c2 datetime, " + "c3 datetime on update now(), " + "c4 char(4));";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
assertThat(listener.total()).isEqualTo(1);
Table t = tables.forTable(new TableId(null, null, "t1"));
assertThat(t).isNotNull();
assertThat(t.columnNames()).containsExactly("c1", "c2", "c3", "c4");
assertThat(t.primaryKeyColumnNames()).containsExactly("c1");
assertColumn(t, "c1", "INT", Types.INTEGER, -1, -1, false, true, true);
assertColumn(t, "c2", "DATETIME", Types.TIMESTAMP, -1, -1, true, false, false);
assertColumn(t, "c3", "DATETIME", Types.TIMESTAMP, -1, -1, true, false, true);
assertColumn(t, "c4", "CHAR", Types.CHAR, 4, -1, true, false, false);
assertThat(t.columnWithName("c1").position()).isEqualTo(1);
assertThat(t.columnWithName("c2").position()).isEqualTo(2);
assertThat(t.columnWithName("c3").position()).isEqualTo(3);
assertThat(t.columnWithName("c4").position()).isEqualTo(4);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParserTest method shouldParseCreateTableWithTextType.
@Test
@FixFor("DBZ-428")
public void shouldParseCreateTableWithTextType() {
String ddl = "CREATE TABLE DBZ428 (" + "limtext TEXT(20), " + "unltext TEXT);";
parser.parse(ddl, tables);
assertThat(tables.size()).isEqualTo(1);
Table mytable = tables.forTable(new TableId(null, null, "DBZ428"));
assertThat(mytable).isNotNull();
assertColumn(mytable, "unltext", "TEXT", Types.VARCHAR, -1, -1, true, false, false);
assertColumn(mytable, "limtext", "TEXT", Types.VARCHAR, 20, -1, true, false, false);
}
use of io.debezium.relational.TableId in project debezium by debezium.
the class MySqlDdlParser method parseDropIndex.
protected void parseDropIndex(Marker start) {
tokens.consume("INDEX");
// index name
String indexName = tokens.consume();
tokens.consume("ON");
TableId tableId = parseQualifiedTableName(start);
consumeRemainingStatement(start);
signalDropIndex(indexName, tableId, start);
debugParsed(start);
}
Aggregations