Revision: 3609
Author: [email protected]
Date: Fri Jun 11 13:42:58 2010
Log: Corrected this critic to use the user defined sql types.
http://code.google.com/p/power-architect/source/detail?r=3609
Modified:
/trunk/src/main/java/ca/sqlpower/architect/ddl/critic/impl/RelationshipMappingTypeCritic.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/ddl/critic/impl/RelationshipMappingTypeCritic.java
Wed Jun 9 12:05:56 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/ddl/critic/impl/RelationshipMappingTypeCritic.java
Fri Jun 11 13:42:58 2010
@@ -30,6 +30,7 @@
import ca.sqlpower.sqlobject.SQLColumn;
import ca.sqlpower.sqlobject.SQLRelationship;
import ca.sqlpower.sqlobject.SQLTable;
+import ca.sqlpower.sqlobject.UserDefinedSQLType;
/**
* Critic that checks for relationships that do not map any columns between
@@ -61,17 +62,25 @@
subject,
"Columns related by FK constraint have different
types",
this,
- new QuickFix("Change type of " +
childTable.getName() + "." + childColumn.getName() + " (child column) to
parent's type") {
+ new QuickFix("Change type of " +
childTable.getName() + "." + childColumn.getName() +
+ " (child column) to " +
parentColumn.getUserDefinedSQLType().getUpstreamType().getName()) {
@Override
public void apply() {
+ UserDefinedSQLType typeToUpdate =
childColumn.getUserDefinedSQLType();
+ UserDefinedSQLType typeToMatch =
parentColumn.getUserDefinedSQLType();
+
typeToUpdate.setUpstreamType(typeToMatch.getUpstreamType());
childColumn.setType(parentColumn.getType());
childColumn.setPrecision(parentColumn.getPrecision());
childColumn.setScale(parentColumn.getScale());
}
},
- new QuickFix("Change type of " +
parentTable.getName() + "." + parentColumn.getName() + " (parent column) to
child's type") {
+ new QuickFix("Change type of " +
parentTable.getName() + "." + parentColumn.getName() +
+ " (parent column) to " +
childColumn.getUserDefinedSQLType().getUpstreamType().getName()) {
@Override
public void apply() {
+ UserDefinedSQLType typeToUpdate =
parentColumn.getUserDefinedSQLType();
+ UserDefinedSQLType typeToMatch =
childColumn.getUserDefinedSQLType();
+
typeToUpdate.setUpstreamType(typeToMatch.getUpstreamType());
parentColumn.setType(childColumn.getType());
parentColumn.setPrecision(childColumn.getPrecision());
parentColumn.setScale(childColumn.getScale());