Composite attribute support - #12
Merged
Merged
Conversation
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.
Adds composite attribute support, following CoreModel #11. Requires CoreModel 2.11.0.
Storage
Composites are expanded into one natively-typed column per leaf element, at any nesting depth — the same strategy CoreData uses, established by reverse engineering a Core Data SQLite store rather than guessing:
Two deliberate deviations from CoreData:
ZLATITUDE,ZLATITUDE1). Path names are deterministic and need no persisted mapping. They also meanPredicateKeyPath.rawValueis the column name, so element predicates and sorts need no rewriting —location.latitude > 30compiles to a plain column reference, nojson_extract.Known limitation
An expanded column layout cannot distinguish an absent composite from one whose elements are all null, so the latter reads back as
.null. This is inherent to the strategy and matches CoreData exactly (verified empirically). Covered byabsentCompositeIsNull.Also included
.arithmeticexpressions (new in CoreModel 2.11.0) are rejected withinvalidPredicaterather than silently mis-translated. Actually implementing arithmetic in SQL is separate work, markedTODO.Testing
10 new tests: column expansion, a schema assertion that leaves are real
REAL/TEXTcolumns, nested round-trips, element and nested-element predicates, sorting, partial and absent composites, and rejection of whole-composite comparison. All 117 tests pass against real SQLite files.