UpdateQuery: marshal false as BOOLEAN if nullzero
tag not set
#937
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.
Related to: #922, see this comment for detailed analysis. This commit demonstrates the bug.
Setting
NullZero = true
for fields withdefault:x
tag led tofalse
values being appended asNULL
inUpdateQuery
.bun/schema/table.go
Lines 378 to 381 in 8a43835
Apart from causing the bug, this seemed like a misuse of
NullZero
property. Removing this behaviour required additional (small) changes toInsertQuery
, so I also added new test cases and extended an existing one to make sure we don't introduce any regressions (hence the many changed files).Finally, I moved the chunky
f.IsPtr && f.HasNilValue(strct), f.HasZeroValue(strct) && (f.NullZero || f.SQLDefault != "")
conditional to a separate method and added some documentation for it.