fix(search): apply the date storage codec to a derived date, and export the codec - #741
Merged
Merged
Conversation
…rt the codec - Convert a `date` derive's ISO 8601 string to the stored Unix seconds, as a path-read date already is; a derive that computed seconds passes through and an unparseable string leaves the field absent - Re-export `isoToUnixSeconds`/`unixSecondsToIso` from the package root, so a schema author no longer reaches into the engine-adapter entry point for the encoding of a field kind they declare - Document the derive return-value contract and the codec's place on the authoring surface
ddeboer
force-pushed
the
worktree-issue-726-export-iso-codec
branch
from
August 14, 2026 13:09
1ed93cc to
b4cd43e
Compare
A derive is the only route a NaN can reach a document by – the read route guards it in `setNumber`. Blessing a derive that computes stored seconds itself makes the case reachable: `Date.parse(bad) / 1000` is NaN, which serializes as `null` and an engine rejects for a numeric field, where the same bad input as an ISO string is simply dropped. Drop it on both routes alike.
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.
A
datefield is stored as Unix seconds. The projection applies that codec to apath-read value, but aderives return value was stored exactly as returned – so a derive handing back an ISO 8601 string wrote a string into a field the collection declaresint64, silently.dategoes through the same storage codec a read one does. A derive states its value in the field’s own terms: an ISO 8601 string is converted, a derive that already computed seconds passes through untouched, and an unparseable string leaves the field absent – exactly as a derive returningundefineddoes. This makes derives consistent with paths, which is what the issue was really about.NaNleaves the field absent too. A derive is the only route aNaNcan reach a document by – the read route guards it insetNumber. Blessing a derive that computes stored seconds itself makes the case reachable (Date.parse(bad) / 1000), andNaNserializes asnull, which an engine rejects for a numeric field. Both routes now drop it alike.isoToUnixSeconds/unixSecondsToIsoare re-exported from the package root. They are the documented encoding of a declared field kind, so they belong next todefineSearchTypeandSearchField. A schema author reaching them only through@lde/search/adapterwas importing from a layer whose contract is “for engine adapters” and whose every other export is irrelevant to them. They stay on/adaptertoo, for the query compiler and the GraphQL surface.Also documents the derive return-value contract on
SearchFieldBase.deriveand the codec’s place on the authoring surface indocs/reference/search.md.Fix #726