Skip to content

Add in-memory store and filtering engine - #26

Merged
colemancda merged 10 commits into
masterfrom
feature/in-memory-store
Jul 21, 2026
Merged

Add in-memory store and filtering engine#26
colemancda merged 10 commits into
masterfrom
feature/in-memory-store

Conversation

@colemancda

@colemancda colemancda commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Adds a pure Swift in-memory store and filtering engine to the CoreModel target, compatible with Embedded Swift and platforms without Foundation.

  • Predicate evaluation engine (Predicate/Evaluate.swift): evaluates any FetchRequest.Predicate against a ModelData instance in memory — comparisons (including cross-numeric-type equality and ordering), compound predicates, string operators (BEGINSWITH, ENDSWITH, CONTAINS, IN, LIKE via a pure Swift wildcard matcher, MATCHES where Foundation regex support is available), relationship comparisons (CONTAINS/IN on to-many, identifier equality on to-one, ANY/ALL modifiers), and custom DatabaseFunction expressions.
  • FetchRequest in-memory execution (FetchRequestEvaluation.swift): filters by entity and predicate, sorts by sort descriptors (property and function terms, stable identifier tiebreaker), and applies fetch offset/limit. Public filtered(by:) / sorted(by:) helpers on [ModelData].
  • InMemoryModelStorage (InMemoryStore.swift): an actor-backed ModelStorage that keeps all objects in memory and evaluates fetch requests with the new engine, validating every operation's entity against a required Model schema. Uses typed throws (CoreModelError) so it also compiles under Embedded Swift, where the untyped-throws protocol conformance is unavailable and the same API is called directly.
  • CoreDataModel now reuses the shared engine: the previous internal, Foundation-only duplicate of predicate evaluation and sorting is removed, and the custom-function fetch path in NSManagedObjectContext delegates to the public CoreModel engine.

Testing

  • swift test: 93 tests pass, including 25 new tests covering predicate evaluation, sorting, fetch request execution, and the in-memory store (CRUD, batch operations, predicates, custom functions, schema validation).
  • swift build (macOS), swift build --swift-sdk wasm, and SWIFT_EMBEDDED=1 swift build --swift-sdk wasm-embedded all succeed.

@github-code-quality

github-code-quality Bot commented Jul 21, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: Swift

Swift / code-coverage/llvm-cov

The overall coverage in commit 97f1ff2 in the feature/in-memory-st... branch remains at 96%, unchanged from commit 935299d in the master branch.

Show a code coverage summary of the most impacted files.
File master 935299d feature/in-memory-st... 97f1ff2 +/-
Sources/CoreDat...ctContext.swift 97% 97% 0%
Sources/CoreDat...valuation.swift 100% 100% 0%
Sources/CoreMod.../Evaluate.swift 0% 96% +96%
Sources/CoreMod...moryStore.swift 0% 100% +100%
Sources/CoreMod...valuation.swift 0% 100% +100%

Updated July 21, 2026 12:57 UTC

@colemancda
colemancda merged commit 790cfe9 into master Jul 21, 2026
32 checks passed
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.

1 participant