Repository navigation
fix(gen): literal go_value in to_where generates &true for pointer type systems - #780
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
The non-null branch of optionalTypePointers built &SRC, which does not compile when SRC is a literal from a relationship to_where go_value (&true, &1). Assign to a local first, as the nullable branch does. Refs stephenafamo#553
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.
With
type_systemset todatabase/sqlorgithub.com/aarondl/opt/null, a relationship whoseto_whereuses a literalgo_valuestill generates code that does not compile. #553 reported it asIsPrimaryVersion = &truein the generated setters, and as&1when the value is unquoted. #556 fixed the other errors in that issue, but this one is still on main.The relationship templates pass the
go_valuestring toTypes.ToOptional. For the two pointer type systems, the non null branch ofoptionalTypePointersbuiltfunc () *T { return &SRC }(), and Go can't take the address of a constant. The nullable branch in the same function already assigns to a local first, so this change uses that form for the non null branch too. A column value passed as SRC behaves the same as before.The new test in
gen/drivers/types_test.gocallsToOptionalwithtrueand1under both type systems. It fails on main withreturn &trueandreturn &1and passes with the change.go test ./gen/drivers/andgo vet ./gen/drivers/pass, and gofmt is clean. I also added a line to the changelog.Michael