Revision: 3976
Author: [email protected]
Date: Fri Nov 5 13:35:04 2010
Log: FIXED BUG 3063: Oracle columns now update nullability correctly. It
was failing before because the DDL generator was not accounting for some
oracle syntax.
http://code.google.com/p/power-architect/source/detail?r=3976
Modified:
/trunk/src/main/java/ca/sqlpower/architect/ddl/OracleDDLGenerator.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ddl/OracleDDLGenerator.java
Fri Jul 9 11:47:49 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/ddl/OracleDDLGenerator.java
Fri Nov 5 13:35:04 2010
@@ -49,6 +49,8 @@
public OracleDDLGenerator() throws SQLException {
super();
}
+
+ private boolean alter = true;
public static final String GENERATOR_VERSION = "$Revision$";
@@ -329,6 +331,17 @@
print(columnDefinition(c,colNameMap));
endStatement(StatementType.MODIFY, c);
}
+
+ /**
+ * We need to tell if the nullability is changing or not because
Oracle syntax requires NULL if
+ * you are changing to NULL, but if is the same, if you add the NULL,
it doesn't work.
+ * Same for NOT NULL. Yay oracle.
+ */
+ public void modifyColumn(SQLColumn c, boolean alter) {
+ this.alter = alter;
+ modifyColumn(c);
+ this.alter = true;
+ }
protected String columnNullability(SQLColumn c) {
GenericTypeDescriptor td = failsafeGetTypeDescriptor(c);
@@ -337,9 +350,9 @@
throw new UnsupportedOperationException
("The data type "+td.getName()+" is not nullable on the target
database platform.");
}
- return " NULL";
+ return alter ? " NULL" : "";
} else {
- return " NOT NULL";
+ return alter ? " NOT NULL" : "";
}
}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
Sat May 22 08:44:54 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/CompareDMFormatter.java
Fri Nov 5 13:35:04 2010
@@ -39,6 +39,7 @@
import ca.sqlpower.architect.ddl.DDLGenerator;
import ca.sqlpower.architect.ddl.LiquibaseDDLGenerator;
+import ca.sqlpower.architect.ddl.OracleDDLGenerator;
import ca.sqlpower.architect.diff.ArchitectDiffException;
import ca.sqlpower.architect.swingui.CompareDMPanel.SourceOrTargetStuff;
import
ca.sqlpower.architect.swingui.CompareDMSettings.SourceOrTargetSettings;
@@ -284,7 +285,17 @@
} else if (chunk.getType() == DiffType.SQL_MODIFIED) {
if (chunk.getData() instanceof SQLColumn) {
SQLColumn c = (SQLColumn) chunk.getData();
- gen.modifyColumn(c);
+
if(OracleDDLGenerator.class.isAssignableFrom(gen.getClass())) {
+ boolean changeNull = false;
+ for (PropertyChange change :
chunk.getPropertyChanges()) {
+ if
(change.getPropertyName().equals("nullable")) {
+ changeNull = true;
+ break;
+ }
+ }
+ ((OracleDDLGenerator)gen).modifyColumn(c,
changeNull);
+ } else
+ gen.modifyColumn(c);
}
for (PropertyChange change : chunk.getPropertyChanges()) {
if (change.getPropertyName().equals("remarks")) {