fix(objectql): apply defaultValue on explicit null at insert (#2706)#2868
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 13 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
背景
修复 #2706 中归属本仓库(objectql)的子问题。
排查结论
applyFieldDefaults现已在beforeInsert之前执行),含回归测试,本次无需再动。null不回填 — 本 PR 修复。current_user— 归属 objectui,本仓库不涉及。改动
applyFieldDefaults原判据为out[f.name] !== undefined,只有"省略"字段才回填 default;表单把未选控件序列化成显式null时会落库null(current_user令牌与静态默认都不生效)。out[f.name] != null:insert 时"省略"与"显式 null"一视同仁,都视为"未提供值"并回填 default。''仍视为真实值,不覆盖。applyFieldDefaults只在insert()调用,update()从不调用它,因此 update 的"置 null"语义完全不受影响。测试
新增两条回归测试(
engine.test.ts):owner:null, status:null→ 回填current_user+ 静态默认;status:''→ 保留空串不覆盖。packages/objectql全部 48 条测试通过。Refs #2706(本仓库子项 #1/#2;#3 归 objectui,保留 issue 开启)