use of org.apache.cayenne.dba.QuotingStrategy 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());
}
};
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class SybaseMergerTokenFactory method createAddColumnToDb.
/**
* @since 3.0
*/
@Override
public MergerToken createAddColumnToDb(DbEntity entity, final DbAttribute column) {
return new AddColumnToDb(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(" ADD ");
boolean magnatory = column.isMandatory();
column.setMandatory(false);
adapter.createTableAppendColumn(sqlBuffer, column);
if (magnatory) {
column.setMandatory(magnatory);
}
return Collections.singletonList(sqlBuffer.toString());
}
};
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class AddColumnToDb method createSql.
@Override
public List<String> createSql(DbAdapter adapter) {
StringBuffer sqlBuffer = new StringBuffer();
QuotingStrategy context = adapter.getQuotingStrategy();
appendPrefix(sqlBuffer, context);
sqlBuffer.append(JdbcAdapter.getType(adapter, getColumn()));
sqlBuffer.append(JdbcAdapter.sizeAndPrecision(adapter, getColumn()));
return Collections.singletonList(sqlBuffer.toString());
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class DropColumnToDb method createSql.
@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 COLUMN ");
sqlBuffer.append(context.quotedName(getColumn()));
return Collections.singletonList(sqlBuffer.toString());
}
use of org.apache.cayenne.dba.QuotingStrategy in project cayenne by apache.
the class SetAllowNullToDb method createSql.
@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(" ALTER COLUMN ");
sqlBuffer.append(context.quotedName(getColumn()));
sqlBuffer.append(" DROP NOT NULL");
return Collections.singletonList(sqlBuffer.toString());
}
Aggregations