use of org.apache.cayenne.dbsync.merge.token.db.SetNotNullToDb in project cayenne by apache.
the class FirebirdMergerTokenFactory method createSetNotNullToDb.
@Override
public MergerToken createSetNotNullToDb(DbEntity entity, DbAttribute column) {
return new SetNotNullToDb(entity, column) {
public List<String> createSql(DbAdapter adapter) {
QuotingStrategy context = adapter.getQuotingStrategy();
String entityName = context.quotedFullyQualifiedName(getEntity());
String columnName = context.quotedName(getColumn());
// but this might be achived by modyfication of system tables
return Collections.singletonList(String.format("UPDATE RDB$RELATION_FIELDS SET RDB$NULL_FLAG = 1 " + "WHERE RDB$FIELD_NAME = '%s' AND RDB$RELATION_NAME = '%s'", columnName, entityName));
}
};
}
use of org.apache.cayenne.dbsync.merge.token.db.SetNotNullToDb in project cayenne by apache.
the class MySQLMergerTokenFactory method createSetNotNullToDb.
@Override
public MergerToken createSetNotNullToDb(final DbEntity entity, final DbAttribute column) {
return new SetNotNullToDb(entity, column) {
@Override
public List<String> createSql(DbAdapter adapter) {
StringBuffer sqlBuffer = new StringBuffer();
QuotingStrategy context = adapter.getQuotingStrategy();
sqlBuffer.append("ALTER TABLE ");
sqlBuffer.append(context.quotedFullyQualifiedName(getEntity()));
sqlBuffer.append(" CHANGE ");
sqlBuffer.append(context.quotedName(getColumn()));
sqlBuffer.append(" ");
adapter.createTableAppendColumn(sqlBuffer, column);
return Collections.singletonList(sqlBuffer.toString());
}
};
}
use of org.apache.cayenne.dbsync.merge.token.db.SetNotNullToDb in project cayenne by apache.
the class IngresMergerTokenFactory method createSetNotNullToDb.
@Override
public MergerToken createSetNotNullToDb(DbEntity entity, DbAttribute column) {
return new SetNotNullToDb(entity, column) {
@Override
public List<String> createSql(DbAdapter adapter) {
/*
* TODO: we generate this query as in ingres db documentation,
* but unfortunately ingres don't support it
*/
StringBuilder sqlBuffer = new StringBuilder();
QuotingStrategy context = adapter.getQuotingStrategy();
sqlBuffer.append("ALTER TABLE ");
sqlBuffer.append(getEntity().getFullyQualifiedName());
sqlBuffer.append(" ALTER COLUMN ");
sqlBuffer.append(context.quotedName(getColumn()));
sqlBuffer.append(" ");
sqlBuffer.append(adapter.externalTypesForJdbcType(getColumn().getType())[0]);
if (adapter.typeSupportsLength(getColumn().getType()) && getColumn().getMaxLength() > 0) {
sqlBuffer.append("(");
sqlBuffer.append(getColumn().getMaxLength());
sqlBuffer.append(")");
}
sqlBuffer.append(" NOT NULL");
return Collections.singletonList(sqlBuffer.toString());
}
};
}
Aggregations