Join core.Documents rows to parent details#7319
Conversation
|
@labkey-adam I tested those attachment parent types and they seemed to work as I'd expect. However, I don't understand your suggested validation steps. When I null out Also, FWIW, the |
Thanks... I omitted the important step of invoking the upgrade code manually. I've updated the steps to include that. I'll look at querying the domains globally, although I didn't see a service method for that. |
@labkey-jeckels I added |
Perf is much better now. <1 sec to render the grid across all containers. Adding that missing repro step repopulates ParentType and enables the join to the Description as expected. |
This just means "orphaned=true", right? Not that there's some conditional formatting on the grid or something. |
Correct |
Both orphaned and global attachments appear on |
Not a concern; they're meant to appear on the page but won't resolve to any tables. |
@labkey-tchad Good catch. Attachments with a Container as parent were resolving to any table with rows in that container (via that table's Container column or similar). I now exclude the container columns to avoid these spurious joins. Try updating and building the latest. There's still a bit of duplication (e.g., data class attachments will be associated with |
|
@labkey-adam Issue found with core.Documents query grid view locally. Per chat with Adam, this looks to be a list issue with a casing discrepancy for the key name: |
Fix verified. Looks good. Tested in PG and MSSQL |
Fix verified. |




Rationale
Improve the
core.Documentsquery by joining to each document's parent and providingParentDescriptionandOrphanedcolumns. This makes it easier to find each parent document and to identify attachments that have been orphaned. https://github.com/LabKey/internal-issues/issues/711Also, fix the extraction of entity IDs from data class LSIDs. At some point, the extraction method got out-of-sync with the LSIDs we produce, which resulted in data class attachment rows not getting correctly populated with their parent type. Once we've tested this PR, I'll add a new SQL script to re-run the upgrade code that populates the
ParentTypecolumn.Some notes and caveats:
nullparent description, so filtering on ParentDescription IS BLANK is a reasonable way to find orphans. However, it may be possible for a parent to have a null description (e.g., a parent document with a null title); the hidden boolean fieldOrphanedprovides a definitive check.<Root>).Changes
AttachmentParentType.getSelectEntityIdAndDescriptionSql()that returns SQL that selects the parents' EntityId and a Description that identifies that parent. ReworkgetSelectParentEntityIdsSql()to simply wrap the new method, selecting only EntityId (to allow use within an IN clause).null.Lsid.getSqlExpressionToExtractObjectId()so it correctly extracts EntityIds from data class LSIDs. Add a junit test to keep this working.LabKeyCollectors.joining(SQLFragment)that joins aStream<SQLFragment>into a single SQLFragment with a delimiter.SQLFragment.join()to correctly handle corner cases like CTEs and temp tokens.Tasks 📍
UPDATE core.Documents SET ParentType = NULL)core.Documentsto ensure all attachments of that type are tagged with the appropriateParentTypeand show a reasonableParentDescriptioncore.DocumentsGroupedByParentType, which allows querying specific projects and folders with a container filter applied.