Repository navigation
feat: rebuild a stored wrapper element without its Parse (IStoredValueRebuild, #488) - #644
Merged
Merged
Conversation
Design only, for the maintainer's decision; no code yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Design approved (maintainer, 2026-11-30) as proposed; TypeKit emitting the interface is a separate TypeKit issue. |
…redValueRebuild (#488) A wrapper element that implements IStoredValueRebuild<TSelf, TPrimitive> over the primitive its family wraps is rebuilt through FromStored wherever the EF Core package rebuilds a stored value: the read of an array column, the write's round-trip check (#53) and a bound element. All three go through the same FromPrimitive, so whatever loads also saves and binds. The round-trip check stays, rebuilt through FromStored. Input keeps Parse: the literal, Parse/TryParse, JSON, and a set inside a JSON document (YearMonthSet<T>'s store text is parsed strictly). YearMonthSet<T> stores a date and its element wraps a YearMonth, so it registers through BridgedVia, which hands the element the month. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t through FromStored (#488) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CaffeinatedCoder
marked this pull request as ready for review
November 30, 2026 17:50
…ugh Parse (#488) The live run showed that ToString of a loaded set holding an old element throws: the core's FormatValue round-trips every element through Parse. The docs say so; whether output should use the rebuild too is the maintainer's call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Maintainer decision recorded on #488: output (ToString/JSON) stays strict, as implemented and documented here. |
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.
Closes #488.
Problem
A wrapper value set (
StringSet<PermissionKey>,Int32Set<OrderId>, …) rebuilt every stored element throughTElement.Parse. Tighten a rule inParseand every row holding an older element stopped loading. Saving it threw too, and so didContains(oldElement), because the write's round-trip check (#53) and a bound element went through the sameParse.Change
As decided on #488 (option 2, the design this PR held as a draft):
IStoredValueRebuild<TSelf, TPrimitive>inCodoMetis.ValueRanges.Core:static abstract TSelf FromStored(TPrimitive stored).TPrimitiveis the primitive the family wraps (string,int,DateOnly, …,YearMonthforYearMonthSet<T>). Over another primitive it is ignored.StringBridgedSetTypeDefinitionandBridgedSetTypeDefinitionfind the interface when their closed definition is built (StoredRebuild.For, an interface lookup, then a helper closed over the element type for thestatic abstractcall). With it,FromPrimitiverebuilds throughFromStored, and the read, the write's round-trip check and the element mapping (a boundContainsoperand) all go throughFromPrimitive, so they agree. The round-trip check stays, rebuilt throughFromStored: an element that formats as other text than it holds is still refused on both legs.Parse: the array literal,Parse/TryParse, JSON, and a set inside a JSON document.ValueSetTypeMapping.ParseStoreTextgets its own strict leg (fromStoreText), which matters forYearMonthSet<T>, the one family that reads its store text throughfromPrimitive.YearMonthSet<T>stores a first-of-monthLocalDatewhile its element wraps aYearMonth, so it registers throughSetTypeRegistry.BridgedVia<LocalDate, YearMonth>, which handsFromStoredthe month. The clone sweep readsBridgedViaasBridged, with a waiver for the extrastoredValueargument.ToStringand JSON of a loaded set still check each element throughParse, so a set holding an elementParsenow refuses throwsInvalidOperationExceptionwhen formatted. It can be loaded, changed and saved. The live test found this and the docs state it as a limit; making output useFromStoredwould need astatic abstractcall from the core's generic sets, which is AOT-hostile.value-sets.md#load-stored-values-after-a-rule-tightens(new) and a sentence inefcore.md. Fragmentchanges/488.md(Added; core, efcore, efcore-nodatime). No answer changes for an element type that doesn't implement the interface.Tests
StoredRebuildBridgeTests(EF, no database; 15 tests): the read, the write check and a bound element, for the string, integer and date families; an element without the interface and one implementing it over the wrong primitive still runParse; a decorating element is refused on both legs; the literal, JSON and a set inside a JSON document still refuse the element. The probe elements refuseoldvalues inParse, andFromStoredbuilds them, so there is no shared switch.NodaStoredRebuildTests(NodaTime EF, no database):YearMonthSet<T>is handed the month; the literal and its store text stay strict.StoredRebuildIntegrationTests(live): writes{old:key},{-7}and{1999-12-01}with SQL, then loads the row, saves it with a new element added, and finds it withContainsof each old element. The literal and JSON still refuse. It uses one database and drops itWITH (FORCE). Not run locally (no Docker for this lane); CI is the authority.StoredRebuildBridgeTestsregistered, with three seeds, one per place, each CAUGHT by its own tests:stored-rebuild-read-runs-parse(3 Read tests),stored-rebuild-write-check-runs-parse(2 Write tests + the 2 Bind tests, which share the leg),stored-rebuild-bound-element-runs-parse(2 Bind tests).V99-stored-value-rebuild-column-only, held by the three classes.MakeGenericType. A case would only test the runtime'sstatic abstractdispatch.FromStoredfromIValueObjectMaterializeris a separate TypeKit issue (not filed here).🤖 Generated with Claude Code