feat(repository): add bulkDelete() and bulkUpdate() for mass operations#147
Merged
clementtalleu merged 1 commit intoMay 11, 2026
Merged
Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
============================================
- Coverage 87.47% 86.85% -0.63%
- Complexity 951 1017 +66
============================================
Files 70 71 +1
Lines 2228 2404 +176
============================================
+ Hits 1949 2088 +139
- Misses 279 316 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implement BulkOperations without loading objects into memory:
- ClassMetadata: expose uniqueConstraints, hasUniqueConstraints(), getUniqueFields()
- MetadataFactory: read #[Unique] property-level and class-level into ClassMetadata
- RedisObjectManager: cache ClassMetadata per class; refactor buildUniqueConstraintPlan()
to read pre-computed metadata instead of repeating reflection on every flush()
- AbstractObjectRepository: lazy ClassMetadata cache via getClassMetadata()
- RedisClientInterface + RedisClient + PredisClient: three new methods:
searchKeys() FT.SEARCH ... NOCONTENT (keys only, no deserialization)
searchKeysWithFields() FT.SEARCH ... RETURN n fields (keys + selected field values)
delMultiple() DEL key1 key2 ... (single command)
- bulkDelete(criteria): FT.SEARCH per batch + delMultiple; unique constraint keys
(unique:{class}:{fields}:{values}) cleaned up automatically
- bulkUpdate(criteria, changes): FT.SEARCH per batch + hMSet/jsonSetProperty per key;
throws BulkOperationException when changes target a unique-constraint field
- BulkOperationException: new exception for invalid bulk update on unique fields
- Functional tests: 18 tests covering Hash and JSON for all scenarios
- docs/advanced_usage.md: bulk operations section with decision table
- README.md: Bulk Operations section + feature list entry
ebe9b66 to
638fcd0
Compare
Contributor
Author
|
@clementtalleu I forgot to mention that for the case of a mass delete, this avoided having to do a foreach loop and call // Before: looping and removing one by one
foreach ($entities as $entity) {
$objectManager->remove($entity);
}
$objectManager->flush();
// After: single bulk delete query
$count = $repository->bulkDelete(['status' => 'inactive']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref: #146
Implement BulkOperations without loading objects into memory:
(unique:{class}:{fields}:{values}) cleaned up automatically
throws BulkOperationException when changes target a unique-constraint field