Skip to content

Rename Mongo-specific repository methods to storage-neutral names, reduce overloads#743

Merged
KrzysztofPajak merged 4 commits into
developfrom
refactor/repository-collection-field-api
Jul 21, 2026
Merged

Rename Mongo-specific repository methods to storage-neutral names, reduce overloads#743
KrzysztofPajak merged 4 commits into
developfrom
refactor/repository-collection-field-api

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Summary

  • Renamed IRepository<T> methods that leaked MongoDB terminology to storage-neutral names: AddToSetAddToCollectionField, UpdateToSetUpdateCollectionFieldItem, PullFilterRemoveCollectionFieldItem, PullRemoveCollectionFieldValue.
  • Collapsed the redundant field == value overloads of UpdateCollectionFieldItem/RemoveCollectionFieldItem into their predicate-based (Expression<Func<U, bool>>) equivalents, since a predicate is a strict superset of a field/value pair. ~49 call sites updated accordingly.
  • Removed the single-caller, no-id mass-update overload of UpdateCollectionFieldItem (used only by ProductTagService.UpdateProductTag to rename a tag across all products); its Mongo/LiteDb implementations relied on fragile ToString()-based matching. Replaced with an explicit find + UpdateField loop in ProductTagService.
  • Fixed a real behavior bug caught by existing tests during the overload merge: LiteDb's predicate-based remove only deleted the first matching array element, while the removed field == value overload (and Mongo's $pull) removes all matches. LiteDb's implementation now removes all matches, consistent with Mongo.

This is prep work for keeping the repository abstraction storage-agnostic (no more MongoDB-only method names/shapes in the shared interface).

Test plan

  • dotnet build GrandNode.sln — 0 errors
  • Grand.Data.Tests (Mongo + LiteDb repository unit tests) — 45/45 passed
  • Grand.Business.Customers.Tests — 118/118 passed
  • Grand.Business.Catalog.Tests — 349/349 passed (1 pre-existing skip)

…d reduce overloads

AddToSet/UpdateToSet/PullFilter/Pull leaked Mongo terminology and had
redundant field==value overloads alongside equivalent predicate-based
ones. Renamed to AddToCollectionField/UpdateCollectionFieldItem/
RemoveCollectionFieldItem/RemoveCollectionFieldValue and collapsed the
field==value overloads into their predicate equivalents, since a
predicate is a strict superset. Also dropped the single-caller,
no-id mass-update overload of UpdateCollectionFieldItem in favor of
inline logic in ProductTagService, since its Mongo/LiteDb
implementations relied on fragile ToString()-based matching.

Along the way, fixed a real bug introduced by the merge: LiteDb's
predicate-based remove only deleted the first matching array element,
while the removed field==value overload (and Mongo's $pull) removed
all matches - caught by existing repository unit tests.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 20, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

KrzysztofPajak and others added 3 commits July 20, 2026 21:05
RemoveCollectionFieldValue was a special case of RemoveCollectionFieldItem
for IEnumerable<string> fields matched by exact equality - both Mongo's
$pull and the predicate-based LiteDb implementation already handle string
element types generically, so the dedicated overload added no capability.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 21, 2026 14:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@KrzysztofPajak
KrzysztofPajak merged commit aaa9358 into develop Jul 21, 2026
5 of 6 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the refactor/repository-collection-field-api branch July 21, 2026 14:36
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants