Skip to content

Commit

Permalink
Fixed 0001559: If there are no primary keys defined when the database…
Browse files Browse the repository at this point in the history
… writer is processing an update or delete report an error.
  • Loading branch information
chenson42 committed Feb 3, 2014
1 parent 277da04 commit 658fb07
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -596,6 +596,18 @@ protected LoadStatus delete(CsvData data, boolean useConflictDetection) {
}
}
}

int lookupKeyCountBeforeLobRemoval = lookupKeys.size();

if (lookupKeys.size() == 0) {
String msg = "There are no keys defined for "
+ targetTable.getFullyQualifiedTableName()
+ ". Cannot build an update statement. ";
if (lookupKeyCountBeforeLobRemoval > 0) {
msg += "The only keys defined are binary and they have been removed.";
}
throw new IllegalStateException(msg);
}

lookupDataMap = getLookupDataMap(data);

Expand Down Expand Up @@ -723,6 +735,8 @@ protected LoadStatus update(CsvData data, boolean applyChangesOnly, boolean useC
lookupKeys = targetTable.getColumnsAsList();
}

int lookupKeyCountBeforeLobRemoval = lookupKeys.size();

if (!platform.getDatabaseInfo().isBlobsWorkInWhereClause()
|| data.isNoBinaryOldData()) {
Iterator<Column> it = lookupKeys.iterator();
Expand All @@ -733,6 +747,16 @@ protected LoadStatus update(CsvData data, boolean applyChangesOnly, boolean useC
}
}
}

if (lookupKeys.size() == 0) {
String msg = "There are no keys defined for "
+ targetTable.getFullyQualifiedTableName()
+ ". Cannot build an update statement. ";
if (lookupKeyCountBeforeLobRemoval > 0) {
msg += "The only keys defined are binary and they have been removed.";
}
throw new IllegalStateException(msg);
}

lookupDataMap = getLookupDataMap(data);

Expand Down

0 comments on commit 658fb07

Please sign in to comment.