use of liquibase.database.core.SybaseDatabase in project liquibase by liquibase.
the class GetViewDefinitionGeneratorSybaseTest method testGenerateSqlForDefaultSchema.
@Test
public void testGenerateSqlForDefaultSchema() {
GetViewDefinitionGeneratorSybase generator = new GetViewDefinitionGeneratorSybase();
GetViewDefinitionStatement statement = new GetViewDefinitionStatement(null, null, "view_name");
Sql[] sql = generator.generateSql(statement, new SybaseDatabase(), null);
assertEquals(1, sql.length);
assertEquals("select text from syscomments where id = object_id('dbo.view_name') order by colid", sql[0].toSql());
}
use of liquibase.database.core.SybaseDatabase in project liquibase by liquibase.
the class GetViewDefinitionGeneratorSybaseTest method testGenerateSqlForNamedSchema.
@Test
public void testGenerateSqlForNamedSchema() {
GetViewDefinitionGeneratorSybase generator = new GetViewDefinitionGeneratorSybase();
GetViewDefinitionStatement statement = new GetViewDefinitionStatement(null, "owner", "view_name");
Sql[] sql = generator.generateSql(statement, new SybaseDatabase(), null);
assertEquals(1, sql.length);
assertEquals("select text from syscomments where id = object_id('OWNER.view_name') order by colid", sql[0].toSql());
}
use of liquibase.database.core.SybaseDatabase in project liquibase by liquibase.
the class AddColumnGeneratorDefaultClauseBeforeNotNull method generateSingleColumnSQL.
@Override
protected String generateSingleColumnSQL(AddColumnStatement statement, Database database) {
String alterTable = " ADD " + database.escapeColumnName(statement.getCatalogName(), statement.getSchemaName(), statement.getTableName(), statement.getColumnName()) + " " + DataTypeFactory.getInstance().fromDescription(statement.getColumnType() + (statement.isAutoIncrement() ? "{autoIncrement:true}" : ""), database).toDatabaseDataType(database);
alterTable += getDefaultClauseBeforeNotNull(statement, database);
if (primaryKeyBeforeNotNull(database)) {
if (statement.isPrimaryKey()) {
alterTable += " PRIMARY KEY";
}
}
if (statement.isAutoIncrement()) {
AutoIncrementConstraint autoIncrementConstraint = statement.getAutoIncrementConstraint();
alterTable += " " + database.getAutoIncrementClause(autoIncrementConstraint.getStartWith(), autoIncrementConstraint.getIncrementBy(), autoIncrementConstraint.getGenerationType(), autoIncrementConstraint.getDefaultOnNull());
}
if (!statement.isNullable()) {
alterTable += " NOT NULL";
} else if ((database instanceof SybaseDatabase) || (database instanceof SybaseASADatabase)) {
alterTable += " NULL";
}
if (!primaryKeyBeforeNotNull(database)) {
if (statement.isPrimaryKey()) {
alterTable += " PRIMARY KEY";
}
}
return alterTable;
}
use of liquibase.database.core.SybaseDatabase in project liquibase by liquibase.
the class CreateTableGeneratorTest method testAutoIncrementSybaseDatabase.
@Test
public void testAutoIncrementSybaseDatabase() throws Exception {
for (Database database : TestContext.getInstance().getAllDatabases()) {
if (database instanceof SybaseDatabase) {
CreateTableStatement statement = new CreateTableStatement(CATALOG_NAME, SCHEMA_NAME, TABLE_NAME);
statement.addColumn(COLUMN_NAME1, DataTypeFactory.getInstance().fromDescription("BIGINT{autoIncrement:true}", database), new AutoIncrementConstraint(COLUMN_NAME1));
Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
assertEquals("Error with " + database, "CREATE TABLE SCHEMA_NAME.TABLE_NAME (COLUMN1_NAME BIGINT IDENTITY NULL)", generatedSql[0].toSql());
}
}
}
Aggregations