IDEMPIERE-2395 - Delete also corrupt records pointing to non-key tables
This commit is contained in:
parent
ec55d45b3d
commit
1d95cc5cba
|
@ -144,17 +144,17 @@ public class CleanOrphanCascade extends SvrProcess
|
||||||
String refTableName = row.get(1).toString();
|
String refTableName = row.get(1).toString();
|
||||||
|
|
||||||
MTable refTable = MTable.get(getCtx(), refTableID);
|
MTable refTable = MTable.get(getCtx(), refTableID);
|
||||||
|
StringBuilder whereClause = new StringBuilder();
|
||||||
|
whereClause.append("AD_Table_ID = ").append(refTableID);
|
||||||
if (refTable.getKeyColumns().length != 1) {
|
if (refTable.getKeyColumns().length != 1) {
|
||||||
log.warning("Wrong reference for table " + tableName + " -> " + refTableName);
|
log.warning("Wrong reference for table " + tableName + " -> " + refTableName);
|
||||||
continue;
|
whereClause.append(" AND Record_ID>0");
|
||||||
}
|
} else {
|
||||||
String colRef = refTable.getKeyColumns()[0];
|
String colRef = refTable.getKeyColumns()[0];
|
||||||
if (isUUIDMap) {
|
if (isUUIDMap) {
|
||||||
colRef = MTable.getUUIDColumnName(refTable.getTableName());
|
colRef = MTable.getUUIDColumnName(refTable.getTableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder whereClause = new StringBuilder();
|
|
||||||
whereClause.append("AD_Table_ID = ").append(refTableID);
|
|
||||||
whereClause.append(" AND NOT EXISTS (SELECT ").append(colRef);
|
whereClause.append(" AND NOT EXISTS (SELECT ").append(colRef);
|
||||||
whereClause.append(" FROM ").append(refTableName).append(" ");
|
whereClause.append(" FROM ").append(refTableName).append(" ");
|
||||||
whereClause.append(" WHERE ").append(refTableName).append(".").append(colRef).append(" = ").append(tableName);
|
whereClause.append(" WHERE ").append(refTableName).append(".").append(colRef).append(" = ").append(tableName);
|
||||||
|
@ -163,6 +163,7 @@ public class CleanOrphanCascade extends SvrProcess
|
||||||
} else {
|
} else {
|
||||||
whereClause.append(".Record_ID)");
|
whereClause.append(".Record_ID)");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int noDel = 0;
|
int noDel = 0;
|
||||||
if (MAttachment.Table_Name.equals(tableName)) {
|
if (MAttachment.Table_Name.equals(tableName)) {
|
||||||
|
|
Loading…
Reference in New Issue