diff --git a/api/src/org/labkey/api/migration/DefaultMigrationSchemaHandler.java b/api/src/org/labkey/api/migration/DefaultMigrationSchemaHandler.java index 019d5f6e30d..08f4fcd3c2c 100644 --- a/api/src/org/labkey/api/migration/DefaultMigrationSchemaHandler.java +++ b/api/src/org/labkey/api/migration/DefaultMigrationSchemaHandler.java @@ -290,7 +290,7 @@ public static void logUnseenAttachmentTypes() Set unseen = new HashSet<>(AttachmentService.get().getAttachmentTypes()); unseen.removeAll(SEEN); - if (SEEN.isEmpty()) + if (unseen.isEmpty()) DatabaseMigrationService.LOG.info("All AttachmentTypes have been seen"); else DatabaseMigrationService.LOG.info("These AttachmentTypes have not been seen: {}", unseen.stream().map(type -> type.getClass().getSimpleName()).collect(Collectors.joining(", "))); diff --git a/assay/src/org/labkey/assay/AssayResultMigrationSchemaHandler.java b/assay/src/org/labkey/assay/AssayResultMigrationSchemaHandler.java index 16e0a57ad82..da9a0a794c2 100644 --- a/assay/src/org/labkey/assay/AssayResultMigrationSchemaHandler.java +++ b/assay/src/org/labkey/assay/AssayResultMigrationSchemaHandler.java @@ -12,18 +12,15 @@ import org.labkey.api.data.SimpleFilter.SQLClause; import org.labkey.api.data.SqlSelector; import org.labkey.api.data.TableInfo; -import org.labkey.api.data.TableSelector; import org.labkey.api.migration.AssaySkipContainers; import org.labkey.api.migration.DatabaseMigrationService.DataFilter; import org.labkey.api.migration.DefaultMigrationSchemaHandler; import org.labkey.api.migration.ExperimentDeleteService; import org.labkey.api.util.GUID; -import org.labkey.api.util.StringUtilsLabKey; import org.labkey.api.util.logging.LogHelper; import org.labkey.assay.plate.PlateReplicateStatsDomainKind; import java.util.Collection; -import java.util.Collections; import java.util.Set; class AssayResultMigrationSchemaHandler extends DefaultMigrationSchemaHandler @@ -38,7 +35,7 @@ public AssayResultMigrationSchemaHandler() private boolean skipTable(TableInfo sourceTable) { // For now, we're ignoring this table since it's empty in our first migration client's database - return Strings.CI.endsWith(sourceTable.getName(), PlateReplicateStatsDomainKind.ASSAY_PLATE_REPLICATE); + return Strings.CI.endsWith(sourceTable.getName(), PlateReplicateStatsDomainKind.NAME); } @Override @@ -63,8 +60,8 @@ public FilterClause getContainerClause(TableInfo sourceTable, Set containe @Override public void addDomainDataFilterClause(OrClause orClause, DataFilter filter, TableInfo sourceTable, Set selectColumnNames) { - // No filtering on assay results for now; just add the passed in containers. Note that these will be filtered - // if AssaySkipContainers is configured. + // No row-by-row filtering on assay results for now; just add the passed in containers. Note that these will be + // filtered by container if AssaySkipContainers is configured. orClause.addClause(getContainerClause(sourceTable, filter.containers())); } @@ -92,9 +89,6 @@ public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilte // Delete exp.Data, exp.Object, etc. rows associated with the rows that weren't copied ExperimentDeleteService.get().deleteDataRows(notCopiedObjectIds); } - - // TODO: Temp! - LOG.info(" " + StringUtilsLabKey.pluralize(new TableSelector(sourceTable, Collections.singleton("DataId")).stream(Integer.class).distinct().count(), "distinct DataId")); } } } diff --git a/experiment/src/org/labkey/experiment/DataClassMigrationSchemaHandler.java b/experiment/src/org/labkey/experiment/DataClassMigrationSchemaHandler.java index 45232046c93..2e93cba7b5d 100644 --- a/experiment/src/org/labkey/experiment/DataClassMigrationSchemaHandler.java +++ b/experiment/src/org/labkey/experiment/DataClassMigrationSchemaHandler.java @@ -90,14 +90,18 @@ public void addDomainDataFilterClause(OrClause orClause, DataFilter filter, Tabl @Override public void afterTable(TableInfo sourceTable, TableInfo targetTable, SimpleFilter notCopiedFilter) { - // Select all ObjectIds associated with the not-copied rows from the source database. Our notCopiedFilter - // works on the data class provisioned table, so we need to use a sub-select (as opposed to a join) to avoid - // ambiguous column references. - SQLFragment objectIdSql = new SQLFragment("SELECT ObjectId FROM exp.Object WHERE ObjectURI IN (SELECT LSID FROM ") - .appendIdentifier(sourceTable.getSelectName()) - .append(" ") - .append(notCopiedFilter.getSQLFragment(sourceTable.getSqlDialect())) - .append(")"); + // Select LSIDs from the just-copied rows in the target table + Collection copiedLsids = new TableSelector(targetTable, Collections.singleton("LSID")).getCollection(String.class); + + // Select all ObjectIds associated with the not-copied rows from the source database + SQLFragment objectIdSql = new SQLFragment("SELECT ObjectId FROM exp.Data d INNER JOIN ") + .appendIdentifier(sourceTable.getSelectName()) + .append(" dc ON d.LSID = dc.LSID"); + + // Don't create an empty IN clause; need to work around issue where "NOT xxx IN (NULL)" evaluates to NULL. + if (!copiedLsids.isEmpty()) + objectIdSql.append(" AND NOT dc.LSID").appendInClause(copiedLsids, sourceTable.getSqlDialect()); + Collection notCopiedObjectIds = new SqlSelector(sourceTable.getSchema(), objectIdSql).getCollection(Long.class); if (notCopiedObjectIds.isEmpty())