Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
PostgreSQL 8.1
Description
The following code has to be added to PostgreSQLBuilder class to make it work for altering columns in PostgreSQL
/**
- Generates the alter statement to add or modify a single column on a table.
* - @param table The table the index is on
- @param column The column to drop
- @param isNewColumn Whether the column should be added
*/
public void writeColumnAlterStmt(Table table, Column column, boolean isNewColumn) throws IOException { writeTableAlterStmt(table); print(isNewColumn ? "ADD " : "ALTER "); if(isNewColumn) writeColumn(table, column); else writeAlterColumn(table, column); printEndOfStatement(); }
/**
- Outputs the DDL for the specified column.
- @param table The table containing the column
- @param column The column
*/
protected void writeAlterColumn(Table table, Column column) throws IOException
{
//see comments in columnsDiffer about null/"" defaults
printIdentifier(getColumnName(column));
print(" TYPE ");
print(getSqlType(column));
if ((column.getDefaultValue() != null) ||
(getPlatformInfo().isIdentitySpecUsesDefaultValue() && column.isAutoIncrement()))
{
if (!getPlatformInfo().isSupportingDefaultValuesForLongTypes() &&
((column.getTypeCode() == Types.LONGVARBINARY) || (column.getTypeCode() == Types.LONGVARCHAR)))
print(" DEFAULT ");
writeColumnDefaultValue(table, column);
}
if (column.isRequired())
else if (getPlatformInfo().isRequiringNullAsDefaultValue() &&
getPlatformInfo().hasNullDefault(column.getTypeCode()))
if (column.isAutoIncrement() && !getPlatformInfo().isIdentitySpecUsesDefaultValue())
{
if (!getPlatformInfo().isSupportingNonPKIdentityColumns() && !column.isPrimaryKey())
print(" ");
writeColumnAutoIncrementStmt(table, column);
}
}