Repository navigation
fix🐛: accept the generator flags a released front end sends as booleans - #966
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The focused compatibility change preserves existing settings, includes regression coverage, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
This PR makes generator configuration saves compatible with released front ends that submit boolean flags, while preserving stored settings rather than interpreting false as disabling authorization.
Changes:
- Adds
GenFlagparsing for integers and numeric strings, treating booleans andnullas unset. - Applies the type to the three generator flags without changing database column types.
- Adds parsing tests and a persistence regression test confirming boolean submissions preserve flags while saving other fields.
| File | Description |
|---|---|
| app/other/models/tools/sys_tables.go | Uses GenFlag for data-scope, Actions, and authorization settings. |
| app/other/models/tools/gen_flag.go | Implements backward-compatible JSON flag parsing. |
| app/other/models/tools/gen_flag_test.go | Tests parsing and preservation of stored flags during updates. |
Review effort: Balanced
go-admin-ui up to v3.4.0 submits isDataScope / isActions / isAuth as booleans, which failed to unmarshal into int and made every save of the code generator config answer 数据解析失败. The front-end fix (go-admin-ui f0e112e) is in no release yet, and the two repositories upgrade independently. Those booleans are always false whatever is stored, so they are read as unset and the stored value is kept, rather than mapped to 2: turning false into "no" would drop the role check from every generated router. Numbers and numeric strings still parse as before.
wenjianzhang
force-pushed
the
fix/gen-flags-accept-bool
branch
from
October 27, 2026 02:25
8d5dfc6 to
11f4070
Compare
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.
问题
用户反馈代码生成配置页保存报
数据解析失败。go-admin-ui v3.4.0 及之前的版本把
isDataScope / isActions / isAuth作为布尔值提交,后端SysTables中这三个字段是int,JSON 解析失败。前端修复(go-admin-uif0e112e,#323)尚未进入任何发布版本,而两个仓库各自独立升级,所以后端需要兼容。修改
新增
tools.GenFlag(1= 是,2= 否),三个字段改用该类型:null视为未传(0)。Updates跳过零值,库中原有设置保持不变;不把
false映射为2:v3.4.0 加载时把1转成"1",提交时判断"1" === 'true',三个值永远是false。如果做映射,每次保存都会把isAuth改成 2,生成的路由就不再检查角色。数据库列类型不变,
gen.go中IsAuth == 2的判断不受影响。验证
gen_flag_test.go:覆盖各种输入的解析;验证 v3.4.0 的请求体保存后,标志位保持不变、其他字段正常写入。1|2|1。修复前,布尔值请求返回数据解析失败。go test ./...、make checksilent通过。