Search in sources :

Example 1 with MysqlSqlTemplate

use of com.alibaba.otter.node.etl.common.db.dialect.mysql.MysqlSqlTemplate in project otter by alibaba.

the class SqlTemplateTest method test_mysql.

@Test
public void test_mysql() {
    SqlTemplate sqlTemplate = new MysqlSqlTemplate();
    // 执行insert
    String sql1 = sqlTemplate.getInsertSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns);
    String sql2 = sqlTemplate.getInsertSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns);
    want.bool(sql1 == sql2);
    // 执行update
    sql1 = sqlTemplate.getUpdateSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns);
    sql2 = sqlTemplate.getUpdateSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns);
    want.bool(sql1 == sql2);
    // 执行deleate
    sql1 = sqlTemplate.getDeleteSql(SCHEMA_NAME, TABLE_NAME, pkColumns);
    sql2 = sqlTemplate.getDeleteSql(SCHEMA_NAME, TABLE_NAME, pkColumns);
    want.bool(sql1 == sql2);
    // 执行merge
    sql1 = sqlTemplate.getMergeSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns, null, true);
    sql2 = sqlTemplate.getMergeSql(SCHEMA_NAME, TABLE_NAME, pkColumns, columns, null, true);
    want.bool(sql1 == sql2);
}
Also used : MysqlSqlTemplate(com.alibaba.otter.node.etl.common.db.dialect.mysql.MysqlSqlTemplate) SqlTemplate(com.alibaba.otter.node.etl.common.db.dialect.SqlTemplate) MysqlSqlTemplate(com.alibaba.otter.node.etl.common.db.dialect.mysql.MysqlSqlTemplate) OracleSqlTemplate(com.alibaba.otter.node.etl.common.db.dialect.oracle.OracleSqlTemplate) Test(org.testng.annotations.Test) BaseDbTest(com.alibaba.otter.node.etl.BaseDbTest)

Aggregations

BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)1 SqlTemplate (com.alibaba.otter.node.etl.common.db.dialect.SqlTemplate)1 MysqlSqlTemplate (com.alibaba.otter.node.etl.common.db.dialect.mysql.MysqlSqlTemplate)1 OracleSqlTemplate (com.alibaba.otter.node.etl.common.db.dialect.oracle.OracleSqlTemplate)1 Test (org.testng.annotations.Test)1