You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
文件首行是 // Code generated by ent, DO NOT EDIT.,Makefile:10 有 go generate ./ent,ent/generate.go 里有对应的 //go:generate。下一次执行 make generate 会把本补丁静默还原,而同批新增的 backend/ent/group_query_test.go(手写文件,不会被覆盖)会继续断言 query.ctx == nil / query.sql == nil,届时变成 CI 红。
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
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.
问题
GroupQuery.Clone在查询上下文或 SQL selector 尚未初始化时会发生空指针异常。根因
克隆逻辑无条件调用
_q.ctx.Clone()和_q.sql.Clone(),未处理这两个字段为nil的情况。改动
为查询上下文和 SQL selector 增加 nil-safe 克隆,并添加覆盖未初始化及已初始化字段的回归测试。未发现重叠 PR。
测试
cd backend && go test ./ent -run TestGroupQueryClone -count=1(passed)cd backend && go vet ./ent(passed)git diff --check(passed)Fixes #5360.