fix(dataview): register full nested HasOne path for fulltext query filter#35
Open
jindrak02 wants to merge 3 commits into
Open
fix(dataview): register full nested HasOne path for fulltext query filter#35jindrak02 wants to merge 3 commits into
jindrak02 wants to merge 3 commits into
Conversation
…ne nested text fields
DataGrid columns whose searchable/sortable text lives inside a HasOne
relation (e.g. `<DataGridTextColumn field={it.author.name} />`) only
registered the last path segment (`"name"`), so the auto-built
`createFullTextFilterHandler` produced a where clause against a
non-existent `Article.name` field instead of `{ author: { name: ... } }`.
The collector proxy now records an absolute `fullPath` on each field
ref's `FIELD_REF_META`, threaded through has-one nesting. `fieldName` /
`path` stay relative (last segment) so selection and relation metadata —
which drive query/selection building via SelectionScope — are unchanged.
The DataGrid column layer reads the dotted `fullPath` via
`extractFieldName`, and `accessField` now traverses dotted paths so
nested cell value extraction works too. Filter/sort handlers already
split on `.` (buildNestedWhere / buildNestedOrderBy), so the dotted path
flows straight through.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The repro comments/title still described the pre-fix failing state. Update them to reflect that the fix threads the full dotted path, so the test now documents the guaranteed behavior rather than a known bug. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #34
Problem
<DataGridTextColumn field={it.author.name} />over a HasOne relation registered the wrong field path for the toolbar<DataGridQueryFilter />: the collector proxy only kept the last accessed segment ("name"), so the auto-builtcreateFullTextFilterHandlerproduced a where clause against a non-existentArticle.namefield — search silently returned zero rows (or failed). Grids whose only text data lives behind aoneHasOne/manyHasOnerelation had no working toolbar search.Fix (option 3 from the issue — the general one)
Thread the absolute dotted path through the collector proxy so nested HasOne fields carry their full chain.
collectorProxy.ts—createCollectorProxy/createCollectorFieldRefnow take aparentPathand compute afullPath(['author', 'name']).fieldName/pathstay relative (last segment) so selection/relation metadata is unaffected; has-many items start a fresh path (dotted where/sort paths only make sense across has-one chains).handles/types.ts—FieldRefMetagains an optionalfullPath?: readonly string[].columns.tsx—extractFieldNamereturns the joinedfullPath("author.name") when present, else the field name.DataGridColumn.renderCellusesaccessFieldfor nested access.columnTypes.ts—accessFieldnow traverses dotted paths through has-one relations.createFullTextFilterHandleralready supported dotted paths viabuildNestedWhere; this just feeds it the correct path.Test
tests/react/dataview/dataGridFulltextNestedFields.test.tsx— a grid whose only text data isit.author.namenow registers theQUERY_FILTER_NAMEhandler and produces{ author: { name: { containsCI: 'John' } } }. Failed onmain, passes here.Test plan
bun test tests/react/dataview/dataGridFulltextNestedFields.test.tsx— 1 passbun run typecheck— clean