Skip to content

Commit

Permalink
0002110: On firebird ddl fails if table column switches from NOT NULL…
Browse files Browse the repository at this point in the history
… to NULLABLE
  • Loading branch information
chenson42 committed Dec 23, 2014
1 parent 8ed5360 commit 431cf13
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -27,6 +27,7 @@
import org.jumpmind.db.alter.AddColumnChange;
import org.jumpmind.db.alter.AddPrimaryKeyChange;
import org.jumpmind.db.alter.ColumnDataTypeChange;
import org.jumpmind.db.alter.ColumnRequiredChange;
import org.jumpmind.db.alter.CopyColumnValueChange;
import org.jumpmind.db.alter.RemoveColumnChange;
import org.jumpmind.db.alter.TableChange;
Expand Down Expand Up @@ -292,6 +293,9 @@ protected void processTableStructureChanges(Database currentModel, Database desi
CopyColumnValueChange copyColumnChange = (CopyColumnValueChange)change;
processChange(currentModel, desiredModel, copyColumnChange, ddl);
changeIt.remove();
} else if (change instanceof ColumnRequiredChange) {
processChange(currentModel, desiredModel, (ColumnRequiredChange) change, ddl);
changeIt.remove();
}
}
for (Iterator<TableChange> changeIt = changes.iterator(); changeIt.hasNext();) {
Expand Down Expand Up @@ -338,6 +342,16 @@ protected boolean writeAlterColumnDataType(ColumnDataTypeChange change, StringBu

return true;
}

protected void processChange(Database currentModel, Database desiredModel,
ColumnRequiredChange change, StringBuilder ddl) {
boolean required = !change.getChangedColumn().isRequired();
ddl.append("update RDB$RELATION_FIELDS set RDB$NULL_FLAG = " + (required ? "1" : "0")
+ " where (RDB$FIELD_NAME = '" + change.getChangedColumn().getName()
+ "') and (RDB$RELATION_NAME = '"
+ getFullyQualifiedTableNameShorten(change.getChangedTable()) + "')");
printEndOfStatement(ddl);
}

/*
* Processes the addition of a column to a table.
Expand Down

0 comments on commit 431cf13

Please sign in to comment.