Author: doogie
Date: Sun May 30 22:08:24 2010
New Revision: 949622
URL:
http://svn.apache.org/viewvc?rev=949622&view=revLog:
getIndexInfo was skipping all indices that were unique. This was wrong, as it meant that declared unique indices wouldn't be detected, and a creation would be attempted, which would then fail, saying it already existed.
Since all PRIMARY KEY constraints have a prefix of 'PK_', just skip all
those indices instead of checking the uniqueness.
Modified:
ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java
Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java?rev=949622&r1=949621&r2=949622&view=diff==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java Sun May 30 22:08:24 2010
@@ -1596,7 +1596,8 @@ public class DatabaseUtil {
if (rsCols.getShort("TYPE") == DatabaseMetaData.tableIndexStatistic) continue;
// HACK: for now skip all "unique" indexes since our foreign key indices are not unique, but the primary key ones are
- if (!rsCols.getBoolean("NON_UNIQUE")) continue;
+ // not correct, declared indices can also be unique
+ // if (!rsCols.getBoolean("NON_UNIQUE")) continue;
String tableName = rsCols.getString("TABLE_NAME");
if (needsUpperCase && tableName != null) {
@@ -1611,6 +1612,7 @@ public class DatabaseUtil {
if (needsUpperCase && indexName != null) {
indexName = indexName.toUpperCase();
}
+ if (indexName.startsWith("PK_") || indexName.startsWith("pk_")) continue;
Set<String> tableIndexList = indexInfo.get(tableName);
if (tableIndexList == null) {