Repository navigation
Preserve nil values when flattening argument lists - #250
Merged
Merged
Conversation
huandu
reviewed
Oct 20, 2026
huandu
left a comment
Owner
There was a problem hiding this comment.
One small test-style suggestion; the Flatten fix itself looks correct.
| {[]interface{}{1, nil, []interface{}{nil, 2}}, []interface{}{1, nil, nil, 2}}, | ||
| {[]interface{}{[]int{}, []int(nil)}, nil}, | ||
| } { | ||
| if got := Flatten(tc.input); !reflect.DeepEqual(got, tc.want) { |
Owner
There was a problem hiding this comment.
Small consistency suggestion: the existing tests in this package use github.com/huandu/go-assert (for example, TestFlatten in modifiers_test.go), while this new test uses reflect.DeepEqual here and again on line 22. Could we switch these assertions to go-assert and drop the reflect import? Functionally this is fine; it just keeps the test suite consistent.
Contributor
Author
There was a problem hiding this comment.
I've switched these to go-assert and dropped the reflect import in f85bd2e. The nil values and SQL arguments are still covered, using the same assertion style as TestFlatten. go test ./... passes.
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.
Preserve nil scalar elements in
FlattenandList.List([]interface{}{1, nil, 2})currently produces two placeholders and drops the SQL NULL argument, while an untyped nil input also contradicts Flatten's scalar contract.Represent a nil leaf as one flattened element while continuing to omit empty slices. The regression fails before the fix; full tests, vet and changed-file gofmt pass.