Repository navigation
Commit 518baca
fix(fields): a lookupFilters { $record } path through or to a multi-valued field is left out with a dev warning (#34618)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99ewj5JRWXTB3u38E9HLhnj)_
Fixes #34389
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:查找字段选择器遇到 `lookupFilters` 里 `{ $record }`
路径经过或指向多值字段(多选关联、tags、关联行上的多值字段)时,不再把列表当标量发出,也不再静默丢弃;该条过滤一律不发,并在开发构建里告警一次,点名路径和多值字段。
- 为什么改:以前直取多值字段会把整个列表塞进 eq 之类的标量比较,经多值关联跳转则悄悄丢掉,作者看不出过滤没生效;规格(#34378
已合)写明这类路径不解析。
- 风险与回滚:只影响写了多值 `$record` 路径的选择器(lint 本就拒收这种写法);单值路径、字面条目、dependsOn
行为不变。回滚即撤销本 PR。
- 先看:`ui/packages/fields/src/widgets/lookupRecordReference.ts` 的
`readRecordPath` 三处 `Array.isArray` 守卫与 `warnMultiValuedPath`;再看测试文件新增的
describe。
- 两分钟验证:`pnpm --filter @object-ui/fields exec vitest run --root ../..
packages/fields/src/widgets/LookupField.recordReference-34197.test.tsx
-t multi-valued`,预期 4 个用例全绿(三种形状 + CONTROL)。
- 需要你做的:无,席位落地。
## What changes
`readRecordPath` (the picker's reader for a `lookupFilters` `{ $record
}` path) now treats a list found anywhere on the path as a multi-valued
path:
- a plain path to a multi-valued field (`tags`) — before: sent with the
whole list as the comparand of a scalar operator;
- a hop through a `multiple: true` lookup (`accounts.cb_market`) —
before: left out silently (`referencedId` finds no id in a list, so
neither a read nor the unreadable-hop warning happened);
- a hop that ends at a multi-valued field of the hop's row
(`account.markets`) — before: sent as a list.
In all three the entry is left out of the candidate query and a
development build warns once per path, through the file's existing
dev-warning channel (now `warnLeftOut`, shared with the unreadable-hop
warning; production builds stay silent as before). The warning names the
path, says it is multi-valued and names where the list sits (the field,
or the lookup that holds a list of records).
The spec half (merged on main) says in
`LookupFilterRecordReferenceSchema`'s describe that such a path "has no
single value: it is not resolved"; the picker now does exactly that. No
`packages/spec/**` change.
## Tests
New `describe` in the existing harness
`ui/packages/fields/src/widgets/LookupField.recordReference-34197.test.tsx`
(one shared harness per component): one case per shape (entry left out
of the candidate query, warning given naming the path and the field) and
a CONTROL (a single-valued field path and a single-valued one-hop path
still resolve, no `[LookupField]` warning). No existing test was
changed.
<details><summary>Package run, type-check and ablations (fix head
2a3ed4f; after the main merge to bc61296121 the card test file re-ran
16/16 on a rebuilt spec)</summary>
- `pnpm --filter '@object-ui/fields^...' build` (dependency closure,
under the verify lock): VERDICT command-exit 0.
- `@object-ui/fields` `pnpm run type-check` (`tsc --noEmit && tsc -p
tsconfig.test.json`; the test file is in the test program, counted with
`--listFiles`): VERDICT command-exit 0.
- `@object-ui/fields` `pnpm test`: Test Files 307 passed, 1 skipped
(308); Tests 4649 passed, 7 skipped (4656); VERDICT command-exit 0.
- Ablations through `scripts/ablation-replace.mjs` (fix committed first;
each guard disabled alone as `if (false && Array.isArray(...))`, anchor
1 -> 0 on disk, restore proven blob == HEAD and `git diff HEAD` empty).
The test imports `./LookupField` from source, so no dist is involved:
- plain-path guard off: "a plain path to a multi-valued field…" red; 1
failed, 3 passed.
- hop-lookup guard off: "a hop through a multiple: true lookup…" red; 1
failed, 3 passed.
- hop-end guard off: "a hop ending at a multi-valued field of the row…"
red; 1 failed, 3 passed.
- The CONTROL stayed green in all three.
</details>
## Acceptance notes
- Detection reads the VALUE (a list on the record or on the hop's row),
not field metadata (`isMultiValueField`). The widget has no field map
for the hop's target object, so a value read is the one signal available
for all three shapes. Consequence: a multi-valued field that is
currently null or unset is left out as an empty value without the
multi-valued warning (the entry is still left out; `os lint` refuses the
path at authoring time). An empty list `[]` now warns as multi-valued
instead of being left out silently as empty.
- The warning is said once per path per page load (module-level set, as
the existing unreadable-hop warning already did).
## Verification
Dispatch-gate derivation (`node scripts/pm/dispatch-gates.mjs --commands
--repo objectstack-ai/objectstack`) run on the final head; every derived
command run locally and reconciled with `--ran`. Families CI owns are
read from this PR's check-runs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmSYVw1sqCsaHSJS9JC
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4ec9cc2 commit 518baca
3 files changed
Lines changed: 191 additions & 23 deletions
File tree
- .changeset
- ui/packages/fields/src/widgets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| |||
170 | 176 | | |
171 | 177 | | |
172 | 178 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
177 | 184 | | |
178 | 185 | | |
179 | 186 | | |
| |||
182 | 189 | | |
183 | 190 | | |
184 | 191 | | |
185 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
186 | 195 | | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
190 | 199 | | |
| 200 | + | |
191 | 201 | | |
192 | 202 | | |
193 | 203 | | |
194 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
195 | 207 | | |
196 | 208 | | |
197 | 209 | | |
198 | 210 | | |
199 | 211 | | |
200 | | - | |
| 212 | + | |
| 213 | + | |
201 | 214 | | |
202 | 215 | | |
203 | 216 | | |
| |||
218 | 231 | | |
219 | 232 | | |
220 | 233 | | |
221 | | - | |
| 234 | + | |
222 | 235 | | |
223 | 236 | | |
224 | | - | |
225 | | - | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
226 | 240 | | |
227 | | - | |
| 241 | + | |
228 | 242 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
238 | 271 | | |
| 272 | + | |
239 | 273 | | |
240 | 274 | | |
241 | 275 | | |
| |||
0 commit comments