-
Notifications
You must be signed in to change notification settings - Fork 7
Join core.Documents rows to parent details #7319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
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 |
| Domain domain = v.getDomain(); | ||
| if (null != domain && domain.getProperties().stream().anyMatch(p -> p.getPropertyType() == PropertyType.ATTACHMENT)) | ||
| selectStatements.add("\n SELECT EntityId AS ID FROM list." + domain.getStorageTableName()); | ||
| selectStatements.add(new SQLFragment("\n SELECT EntityId, ? AS Description FROM list.", domain.getName()).append(domain.getStorageTableName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it would be useful to concatenate the PK of the list row too.
| // requires querying and re-filtering the source tables instead. | ||
| Collection<AttachmentParentType> ret = new LinkedList<>(); | ||
|
|
||
| // TODO: Select ParentType as well to avoid duplication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this TODO for now or later?
Rationale
Improve the
core.Documentsquery by joining to each document's parent and providingParentDescriptionandOrphanedcolumn. This makes it easier to find the parent document and highlights 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 aString<SQLFragment>into a single SQLFragment.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.