Search in sources :

Example 1 with DropColumnToDb

use of org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb in project cayenne by apache.

the class IngresMergerTokenFactory method createDropColumnToDb.

@Override
public MergerToken createDropColumnToDb(DbEntity entity, DbAttribute column) {
    return new DropColumnToDb(entity, column) {

        @Override
        public List<String> createSql(DbAdapter adapter) {
            StringBuilder buf = new StringBuilder();
            QuotingStrategy context = adapter.getQuotingStrategy();
            buf.append("ALTER TABLE ");
            buf.append(context.quotedFullyQualifiedName(getEntity()));
            buf.append(" DROP COLUMN ");
            buf.append(context.quotedName(getColumn()));
            buf.append(" RESTRICT ");
            return Collections.singletonList(buf.toString());
        }
    };
}
Also used : DropColumnToDb(org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb) DbAdapter(org.apache.cayenne.dba.DbAdapter) QuotingStrategy(org.apache.cayenne.dba.QuotingStrategy)

Example 2 with DropColumnToDb

use of org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb in project cayenne by apache.

the class SybaseMergerTokenFactory method createDropColumnToDb.

/**
 * @since 3.0
 */
@Override
public MergerToken createDropColumnToDb(DbEntity entity, DbAttribute column) {
    return new DropColumnToDb(entity, column) {

        @Override
        public List<String> createSql(DbAdapter adapter) {
            StringBuilder sqlBuffer = new StringBuilder();
            QuotingStrategy context = adapter.getQuotingStrategy();
            sqlBuffer.append("ALTER TABLE ");
            sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
            sqlBuffer.append(" DROP ");
            sqlBuffer.append(context.quotedName(getColumn()));
            return Collections.singletonList(sqlBuffer.toString());
        }
    };
}
Also used : DropColumnToDb(org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb) DbAdapter(org.apache.cayenne.dba.DbAdapter) QuotingStrategy(org.apache.cayenne.dba.QuotingStrategy)

Example 3 with DropColumnToDb

use of org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb in project cayenne by apache.

the class TokenSortTest method testToDbTokensCompare.

@Test
public void testToDbTokensCompare() throws Exception {
    List<MergerToken> tokens = Arrays.<MergerToken>asList(new DropColumnToDb(null, null), new DropRelationshipToDb(null, null), new DropTableToDb(null), new AddColumnToModel(null, null), new AddRelationshipToDb(null, null), new AddColumnToDb(null, null), new CreateTableToDb(null));
    Collections.sort(tokens);
    List<String> actual = toClassesNames(tokens);
    List<String> expected = Arrays.asList("DropRelationshipToDb", "DropColumnToDb", "DropTableToDb", "CreateTableToDb", "AddColumnToDb", "AddColumnToModel", "AddRelationshipToDb");
    assertEquals(expected, actual);
}
Also used : AddColumnToDb(org.apache.cayenne.dbsync.merge.token.db.AddColumnToDb) CreateTableToDb(org.apache.cayenne.dbsync.merge.token.db.CreateTableToDb) DropColumnToDb(org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb) AddRelationshipToDb(org.apache.cayenne.dbsync.merge.token.db.AddRelationshipToDb) DropTableToDb(org.apache.cayenne.dbsync.merge.token.db.DropTableToDb) DropRelationshipToDb(org.apache.cayenne.dbsync.merge.token.db.DropRelationshipToDb) AddColumnToModel(org.apache.cayenne.dbsync.merge.token.model.AddColumnToModel) Test(org.junit.Test)

Aggregations

DropColumnToDb (org.apache.cayenne.dbsync.merge.token.db.DropColumnToDb)3 DbAdapter (org.apache.cayenne.dba.DbAdapter)2 QuotingStrategy (org.apache.cayenne.dba.QuotingStrategy)2 AddColumnToDb (org.apache.cayenne.dbsync.merge.token.db.AddColumnToDb)1 AddRelationshipToDb (org.apache.cayenne.dbsync.merge.token.db.AddRelationshipToDb)1 CreateTableToDb (org.apache.cayenne.dbsync.merge.token.db.CreateTableToDb)1 DropRelationshipToDb (org.apache.cayenne.dbsync.merge.token.db.DropRelationshipToDb)1 DropTableToDb (org.apache.cayenne.dbsync.merge.token.db.DropTableToDb)1 AddColumnToModel (org.apache.cayenne.dbsync.merge.token.model.AddColumnToModel)1 Test (org.junit.Test)1