Permalink
Browse files

[BZ205810] Exception thrown upon trying to edit a MYSQL table with fo…

…reign key
  • Loading branch information...
jgraham
jgraham committed Mar 25, 2008
1 parent cca2ae7 commit d9845f39f19f6e0bbb1a394e30dc1cdd3e3e4bac
@@ -27,17 +27,9 @@
import org.eclipse.datatools.connectivity.sqm.internal.core.RDBCorePlugin;
import org.eclipse.datatools.enablement.mysql.MysqlPlugin;
import org.eclipse.datatools.modelbase.dbdefinition.PredefinedDataTypeDefinition;
-import org.eclipse.datatools.modelbase.sql.constraints.IncrementType;
-import org.eclipse.datatools.modelbase.sql.constraints.Index;
-import org.eclipse.datatools.modelbase.sql.constraints.IndexMember;
-import org.eclipse.datatools.modelbase.sql.constraints.PrimaryKey;
-import org.eclipse.datatools.modelbase.sql.constraints.SQLConstraintsPackage;
+import org.eclipse.datatools.modelbase.sql.constraints.*;
import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType;
-import org.eclipse.datatools.modelbase.sql.schema.Database;
-import org.eclipse.datatools.modelbase.sql.schema.IdentitySpecifier;
-import org.eclipse.datatools.modelbase.sql.schema.ReferentialActionType;
-import org.eclipse.datatools.modelbase.sql.schema.SQLSchemaPackage;
-import org.eclipse.datatools.modelbase.sql.schema.Schema;
+import org.eclipse.datatools.modelbase.sql.schema.*;
import org.eclipse.datatools.modelbase.sql.tables.BaseTable;
import org.eclipse.datatools.modelbase.sql.tables.Column;
import org.eclipse.datatools.modelbase.sql.tables.SQLTablesPackage;
@@ -87,10 +79,22 @@ public Database getCatalogDatabase() {
}
public PrimaryKey getPrimaryKey() {
- if (!this.pkLoaded)
- this.loadPrimaryKey();
- return super.getPrimaryKey();
+ if (!this.pkLoaded)
+ this.loadPrimaryKey();
+ return doGetPrimaryKey();
}
+
+ private PrimaryKey doGetPrimaryKey() {
+ Iterator allConstraints = super.getConstraints().iterator();
+ while( allConstraints.hasNext() ) {
+ Constraint currentConstraint = (Constraint)allConstraints.next();
+ if (currentConstraint instanceof PrimaryKey) {
+ return (PrimaryKey)currentConstraint;
+ }
+ }
+ return null;
+ }
+
public EList getColumns() {
if (!this.columnsLoaded)

0 comments on commit d9845f3

Please sign in to comment.