Search in sources :

Example 1 with CockroachDatabase

use of liquibase.database.core.CockroachDatabase in project liquibase by liquibase.

the class AlterSequenceGeneratorTest method testAlterSequenceCycleDatabase.

// @Test
// public void h2DatabaseSupportsSequenceMaxValue() throws Exception {
// 
// H2Database h2Database = new H2Database();
// h2Database.setConnection(mockedSupportedMinMaxSequenceConnection);
// 
// AlterSequenceStatement alterSequenceStatement = createSampleSqlStatement();
// alterSequenceStatement.setMaxValue(new BigInteger("1000"));
// 
// assertFalse(generatorUnderTest.validate(alterSequenceStatement, h2Database, new MockSqlGeneratorChain()).hasErrors());
// }
// @Test
// public void h2DatabaseDoesNotSupportsSequenceMaxValue() throws Exception {
// 
// H2Database h2Database = new H2Database();
// h2Database.setConnection(mockedUnsupportedMinMaxSequenceConnection);
// 
// AlterSequenceStatement alterSequenceStatement = createSampleSqlStatement();
// alterSequenceStatement.setMaxValue(new BigInteger("1000"));
// 
// assertTrue(generatorUnderTest.validate(alterSequenceStatement, h2Database, new MockSqlGeneratorChain()).hasErrors());
// }
// @Test
// public void h2DatabaseSupportsSequenceMinValue() throws Exception {
// 
// H2Database h2Database = new H2Database();
// h2Database.setConnection(mockedSupportedMinMaxSequenceConnection);
// 
// AlterSequenceStatement alterSequenceStatement = createSampleSqlStatement();
// alterSequenceStatement.setMinValue(new BigInteger("10"));
// 
// assertFalse(generatorUnderTest.validate(alterSequenceStatement, h2Database, new MockSqlGeneratorChain()).hasErrors());
// }
// 
// @Test
// public void h2DatabaseDoesNotSupportsSequenceMinValue() throws Exception {
// 
// H2Database h2Database = new H2Database();
// h2Database.setConnection(mockedUnsupportedMinMaxSequenceConnection);
// 
// AlterSequenceStatement alterSequenceStatement = createSampleSqlStatement();
// alterSequenceStatement.setMinValue(new BigInteger("10"));
// 
// assertTrue(generatorUnderTest.validate(alterSequenceStatement, h2Database, new MockSqlGeneratorChain()).hasErrors());
// }
@Test
public void testAlterSequenceCycleDatabase() {
    for (Database database : TestContext.getInstance().getAllDatabases()) {
        AlterSequenceStatement statement = createSampleSqlStatement();
        statement.setCycle(false);
        Sql[] generatedSql = this.generatorUnderTest.generateSql(statement, database, null);
        if (database instanceof OracleDatabase) {
            assertEquals("ALTER SEQUENCE CATALOG_NAME.SEQUENCE_NAME NOCYCLE", generatedSql[0].toSql());
        } else if (database instanceof PostgresDatabase || database instanceof CockroachDatabase) {
            assertEquals("ALTER SEQUENCE SCHEMA_NAME.SEQUENCE_NAME NO CYCLE", generatedSql[0].toSql());
        }
    }
}
Also used : OracleDatabase(liquibase.database.core.OracleDatabase) CockroachDatabase(liquibase.database.core.CockroachDatabase) PostgresDatabase(liquibase.database.core.PostgresDatabase) PostgresDatabase(liquibase.database.core.PostgresDatabase) OracleDatabase(liquibase.database.core.OracleDatabase) Database(liquibase.database.Database) CockroachDatabase(liquibase.database.core.CockroachDatabase) AlterSequenceStatement(liquibase.statement.core.AlterSequenceStatement) Sql(liquibase.sql.Sql) Test(org.junit.Test) AbstractSqlGeneratorTest(liquibase.sqlgenerator.AbstractSqlGeneratorTest)

Aggregations

Database (liquibase.database.Database)1 CockroachDatabase (liquibase.database.core.CockroachDatabase)1 OracleDatabase (liquibase.database.core.OracleDatabase)1 PostgresDatabase (liquibase.database.core.PostgresDatabase)1 Sql (liquibase.sql.Sql)1 AbstractSqlGeneratorTest (liquibase.sqlgenerator.AbstractSqlGeneratorTest)1 AlterSequenceStatement (liquibase.statement.core.AlterSequenceStatement)1 Test (org.junit.Test)1