fix(rest): split multi-value fields on import so multiple:true columns resolve per-token (#3063)#3068
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 7 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…s resolve per-token (#3063)
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 #3063.
Problem
The bulk-import coercion (
packages/rest/src/import-coerce.ts) resolved a reference cell as a single value regardless of the field'smultipleflag. Amultiple: truelookup/user cell like张焊工;李质检was handed whole to name resolution and always failed withno <object> matches "张焊工;李质检"— so every multi-value association had to be back-filled by hand in the record UI after import. Single-value lookups imported fine.Fix
Coercion now mirrors objectql's
isMultiValueFieldpredicate (source of truth inrecord-validator.ts; the spec —field.zod.ts:392— allowsmultipleon select / lookup / file / image, withradiosharing select's branch andusersharing lookup's). A field whose stored value is an array — an inherently-multi type (multiselect/checkboxes/tags) or a multi-capable type flaggedmultiple: true— has its cell split on the export separator (,/;/、/ newline) and each token coerced individually:multiple: true) → resolve each name token to an id, store the id array; an unmatched/ambiguous token reports the specific token (no sys_user matches "查无此人"), not the whole string.multiple: true) → match each token against the options, store the option-value array.multiple: true) → split into an id/url array.Non-multi-capable reference types (master_detail / reference / tree) and all single-value fields are unchanged — a stray
multiple: trueon them stays a single resolved value, matching the engine. This is the exact inverse ofexport-format.ts'sformatReferencearray join.Tests
import-coerce.test.ts— multi-value lookup split + per-token failure naming; select+multiple; file/image+multiple; master_detailmultipleignored (engine parity).import-integration.test.ts— end-to-end through the real engine: CSV张三;李四→['u1','u2']on insert; select+multiple → option-value array; per-token not-found.Manual verification (showcase, real engine + schema)
Ran the showcase backend and hit
POST /api/v1/data/showcase_field_zoo/importagainstf_users(Field.user({ multiple: true })):张焊工;李质检(issue's exact case)["TK3hh…","csQj…"]张焊工,李质检(comma)张焊工;查无此人f_users: no sys_user matches "查无此人"— names the bad token only