use of liquibase.statement.core.InsertStatement in project liquibase by liquibase.
the class InsertOrUpdateGeneratorOracleTest method testInsertSequenceValWithSchema.
@Test
public void testInsertSequenceValWithSchema() {
OracleDatabase database = new OracleDatabase();
InsertGenerator generator = new InsertGenerator();
InsertStatement statement = new InsertStatement("mycatalog", "myschema", "mytable");
ColumnConfig columnConfig = new ColumnConfig();
columnConfig.setValueSequenceNext(new SequenceNextValueFunction("myschema.my_seq"));
columnConfig.setName("col3");
statement.addColumn(columnConfig);
Sql[] sql = generator.generateSql(statement, database, null);
String theSql = sql[0].toSql();
assertEquals("INSERT INTO mycatalog.mytable (col3) VALUES (\"myschema\".\"my_seq\".nextval)", theSql);
}
use of liquibase.statement.core.InsertStatement in project liquibase by liquibase.
the class InsertOrUpdateGeneratorPostgresTest method testInsertSequenceValWithSchema.
@Test
public void testInsertSequenceValWithSchema() {
PostgresDatabase postgresDatabase = new PostgresDatabase();
InsertGenerator generator = new InsertGenerator();
InsertStatement statement = new InsertStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
ColumnConfig columnConfig = new ColumnConfig();
columnConfig.setValueSequenceNext(new SequenceNextValueFunction(SCHEMA_NAME + '.' + SEQUENCE_NAME));
columnConfig.setName("col3");
statement.addColumn(columnConfig);
Sql[] sql = generator.generateSql(statement, postgresDatabase, null);
String theSql = sql[0].toSql();
assertEquals(String.format("INSERT INTO %s.%s (col3) VALUES (nextval('%s.%s'))", SCHEMA_NAME, TABLE_NAME, SCHEMA_NAME, SEQUENCE_NAME), theSql);
}
use of liquibase.statement.core.InsertStatement in project liquibase by liquibase.
the class CustomChange method generateStatements.
@Override
public SqlStatement[] generateStatements(Database database) throws CustomChangeException {
SqlStatement[] st = new SqlStatement[1];
InsertStatement is = new InsertStatement(null, null, "persons");
is.addColumnValue("id", new Integer(1));
is.addColumnValue("firstname", "joan");
is.addColumnValue("lastname", "pujol");
st[0] = is;
return st;
}
Aggregations