Repository navigation
Fix int32/int64 cast order in dbtest faker - #70
Merged
Merged
Conversation
- Cast the fake value before assignment in ByNameAndType and ByType: int64(in.X = ...) is not valid Go and aborted dbtest generation for models with int32/int64 columns since #62 - Add TestFakeFiller_IntCast for int32/int64 columns
DmiTryAgain
approved these changes
Oct 9, 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.
Problem
Since #62 (the fix for #56), dbtest wraps the int32/int64 cast around the
whole assignment:
This is not valid Go, so in v0.6.1
mfd-generator dbtestfails to formatthe output and aborts on any model with a non-nullable column mapped to
int32orint64(e.g.int8/bigint).Fix
Cast the fake value first, then assign:
toInt64().assign(col)instead ofassign(col).toInt64(), in bothByNameAndTypeandByType:Tests
TestFakeFiller_IntCast: int32/int64 columns viaByTypeandByNameAndTypeproduce the expected statement, and it parses as Go.Fails on master, passes with the fix.
intexcept onenullable
*int64, which is not faked, so the golden files did not catchthis.