use of liquibase.database.core.MSSQLDatabase in project liquibase by liquibase.
the class MssqlIntegrationTest method dataTypeParamsTest.
@Test
public void dataTypeParamsTest() throws Exception {
if (this.getDatabase() == null) {
return;
}
Liquibase liquibase = createLiquibase("changelogs/mssql/issues/data.type.params.xml");
liquibase.update((String) null);
DatabaseSnapshot snapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(CatalogAndSchema.DEFAULT, this.getDatabase(), new SnapshotControl(getDatabase()));
for (Table table : snapshot.get(Table.class)) {
if (getDatabase().isLiquibaseObject(table)) {
continue;
}
for (Column column : table.getColumns()) {
String expectedType = column.getName().split("_")[0];
String foundTypeDefinition = DataTypeFactory.getInstance().from(column.getType(), new MSSQLDatabase()).toDatabaseDataType(getDatabase()).toString();
assertFalse("Parameter found in " + table.getName() + "." + column.getName(), foundTypeDefinition.contains("("));
}
}
}
use of liquibase.database.core.MSSQLDatabase in project liquibase by liquibase.
the class TagDatabaseGeneratorTest method testMSSQL.
//// @Test
//// public void supports() throws Exception {
//// new DatabaseTestTemplate().testOnAllDatabases(new DatabaseTest() {
//// public void performTest(Database database) throws Exception {
//// assertTrue(createGeneratorUnderTest().supportsDatabase(database));
//// }
//// });
//// }
//
// @Test
// public void execute() throws Exception {
// new DatabaseTestTemplate().testOnAvailableDatabases(
// new SqlStatementDatabaseTest(null, new TagDatabaseStatement("TAG_NAME")) {
// protected void setup(Database database) throws Exception {
// new Liquibase("changelogs/common/common.tests.changelog.xml", new JUnitResourceAccessor(), database).update(null);
// }
//
// protected void preExecuteAssert(DatabaseSnapshotGenerator snapshot) throws DatabaseException {
// assertFalse(snapshot.getDatabase().doesTagExist("TAG_NAME"));
// }
//
// protected void postExecuteAssert(DatabaseSnapshotGenerator snapshot) throws DatabaseException {
// assertTrue(snapshot.getDatabase().doesTagExist("TAG_NAME"));
// }
//
// });
// }
@Test
public void testMSSQL() throws Exception {
TagDatabaseStatement statement = new TagDatabaseStatement("v1.0");
Sql[] sql = SqlGeneratorFactory.getInstance().generateSql(statement, new MSSQLDatabase());
assertEquals(1, sql.length);
assertEquals("UPDATE [changelog] " + "SET [TAG] = 'v1.0' " + "FROM [DATABASECHANGELOG] AS [changelog] " + "INNER JOIN (" + "SELECT TOP (1) [ID], [AUTHOR], [FILENAME] " + "FROM [DATABASECHANGELOG] " + "ORDER BY [DATEEXECUTED] DESC, [ORDEREXECUTED] DESC" + ") AS [latest] " + "ON [latest].[ID] = [changelog].[ID] " + "AND [latest].[AUTHOR] = [changelog].[AUTHOR] " + "AND [latest].[FILENAME] = [changelog].[FILENAME]", sql[0].toSql());
}
use of liquibase.database.core.MSSQLDatabase in project liquibase by liquibase.
the class UpdateGeneratorTest method testGenerateSqlWithNameValuePlaceholderPairs.
@Test
public void testGenerateSqlWithNameValuePlaceholderPairs() {
// given
Database database = new MSSQLDatabase();
UpdateStatement statement = new UpdateStatement(null, null, "DATABASECHANGELOG").addNewColumnValue("MD5SUM", "7:e27bf9c0c2313160ef960a15d44ced47").setWhereClause(":name = :value AND :name = :value AND :name = :value").addWhereColumnName("ID").addWhereColumnName("AUTHOR").addWhereColumnName("FILENAME").addWhereParameters("SYPA: AUTO_START tüüp INT -> TEXT, vaartus 0 00 17 * * ?", "martin", "db/changelog.xml");
UpdateGenerator generator = new UpdateGenerator();
// when
Sql[] sqls = generator.generateSql(statement, database, null);
// then
assertEquals("UPDATE [DATABASECHANGELOG] " + "SET [MD5SUM] = '7:e27bf9c0c2313160ef960a15d44ced47' " + "WHERE [ID] = N'SYPA: AUTO_START tüüp INT -> TEXT, vaartus 0 00 17 * * ?' " + "AND [AUTHOR] = 'martin' " + "AND [FILENAME] = 'db/changelog.xml'", sqls[0].toSql());
}
Aggregations