Skip to content
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

Fix for removing old indexes when resource is updated #1840

Merged
merged 5 commits into from
Feb 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added comments
  • Loading branch information
aditya-07 committed Feb 6, 2023
commit e37d8e612e227d91e39d17b4f33f9c0afc0b856a
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ internal abstract class ResourceDao {
open suspend fun update(resource: Resource) {
getResourceEntity(resource.logicalId, resource.resourceType)?.let {
val entity = it.copy(serializedResource = iParser.encodeResourceToString(resource))
// The foreign key in Index entity tables is set with cascade delete constraint and
// insertResource has REPLACE conflict resolution. So, when we do an insert to update the
// resource, it deletes old resource and corresponding index entities (based on foreign key
// constrain) before inserting the new resource.
insertResource(entity)
aditya-07 marked this conversation as resolved.
Show resolved Hide resolved
val index = ResourceIndexer.index(resource)
val index = resourceIndexer.index(resource)
updateIndicesForResource(index, entity, it.resourceUuid)
}
?: throw ResourceNotFoundException(resource.resourceType.name, resource.id)
Expand Down