Repository navigation
query: honor omitempty on embedded struct fields - #199
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #199 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 165 127 -38
=========================================
- Hits 165 127 -38 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
willnorris
approved these changes
Oct 28, 2026
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.
An anonymous struct tagged
url:",omitempty"is queued for traversal before its emptiness is checked. A zero value with anIsZero() boolmethod therefore still adds its promoted fields to the query, while an explicitly named field of the same type is omitted.Check
omitemptybefore queuing embedded structs. TheIsZeroassertion also checks reflection accessibility so unexported embedded structs continue to expose their exported fields without panicking. Kind-based emptiness checks remain unchanged, including zero private scalar embeds and nil pointers; non-nil pointers still encode their contents.Fixes #198.
Validation on Go 1.26.8, linux/amd64:
965d79f) with an unexpected empty query parameter, and passes with this change.go test -race -coverprofile coverage.txt -covermode atomic ./...— passes, 100% statement coverage.go test -shuffle=on ./...,go vet ./..., andgo build ./...— pass.golangci-lint run ./...— zero issues with the repository's pinned v2.1.2 and its existing configuration.Other Go versions are left to the upstream CI matrix. No dependencies or public APIs are added.