Repository navigation
schema 中的可选字段从 Optional 迁到 Option - #87
Merged
Merged
Conversation
calcit 0.32 schedules the legacy `Optional<T>` for removal (calcit#2233). All 13 uses in app.schema now declare `Option`: ClientStore :user/:diary, ClientUser and User :avatar, CursorPatch fields, Diary :date/:time, Page :time, Router :data, Session :user-id. Constructors, updaters and views write and read `Option` explicitly instead of nil, so `nil->option` around these fields is gone. Boundaries keep accepting older data: - Stored databases that hold nil (legacy maps or typed records written before this change) fail the typed parse and go through the existing legacy migration; `normalize-stored-struct` now drops nil fields so they decode as `Option :none`. - Legacy client map payloads drop nil fields the same way. - Option values lose their nominal declaration on the websocket, so `normalize-wire-value` drops `:none` entries and unwraps `:some` before decoding the ClientStore. New tests cover the server-to-client round trip, typed diary payloads, and migration of nil-era storage; the JS boundary fixture now uses the new wire shape and checks Option variants arriving over the socket. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019bPdumddHcfQCCCVRuVyXS
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.
Requested by Jon · project thread
改动
calcit 0.32 计划删除旧的
Optional<T>(calcit-lang/calcit#2233,calcit 0.33.0 里程碑)。本仓库 13 处命中全部在app.schema和一个测试的 hint 里,现在都改成Option:ClientStore的:user、:diaryClientUser、User的:avatarCursorPatch的:year/:month/:dayDiary的:date、:time,Page的:timeRouter的:data,Session的:user-id构造、updater 和视图都改为显式写
Option :some/Option :none,读取用match/.unwrap-or/option:some?,这些字段上的nil->option都去掉了。改完后calcit.cirru中不再有Optional。兼容旧数据(需要重点看)
storage.cirru里是 nil(旧 map 或这次之前写出的 typed record)。它们在 typed 解析时会失败,走已有的 legacy 迁移流程(先备份再原子替换)。normalize-stored-struct现在会丢掉值为 nil 的字段,于是解码得到Option :none;原来的:time 123等值得到Option :some。新增测试migrates-typed-storage-written-with-nil-optionals用这次之前的真实 typed 格式文本验证,normalizes-empty-legacy-records也补了断言和迁移后 typed 往返。部署后第一次启动会触发一次迁移并生成.legacy-backup.cirru。normalize-client-payload同样丢掉 nil 字段。format-cirru-edn/ recollect 传到客户端后变成没有名义声明的:some/:none变体,0.31.0 的decode-map-as不认。normalize-wire-value现在会丢掉:none条目、拆开:some,再解码ClientStore。新增wire-option?辅助函数。测试
twig-container#optional-fields-round-trip-over-wire:服务端 twig →diff-twig→ 文本 → 客户端try-client-message,覆盖登录和未登录两种 store。parse-client-op#preserves-optional-diary-fields-in-typed-payload。tests/credentials-host.mjs的 fixture 同步更新,月份/年份按钮的断言改读 Option,并加了一段从 socket 收到:some/:none变体的检查。本地验证(calcit 0.31.0,与 deps 钉的版本一致)
caps --ci、yarn install --immutable、caps verify --toolchainfix --workflow strict --verify:passed,无 diagnosticsedit format后无 diff--check-only,以及两组--ns检查都通过yarn test-boundaries通过(server 入口 79 个测试 + JS 重放)yarn compile-page+release-page构建成功另外用 0.32.1 试了一下:项目在升级到 0.32 前还有别的阻塞(比如
E_LEGACY_TYPE_SYNTAX),和这次改动无关。Generated by Claude Code