-
-
Save amy/8e8e075eef98d377c44e5259303a72ea to your computer and use it in GitHub Desktop.
This file contains 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
Goal: map result of query onto foo. | |
Issue: Only one of the structs is in the array. | |
I'm using gorm as an ORM. | |
type Bar struct { | |
test1 string | |
test2 string | |
} | |
var foo []Bar | |
someQuery := "... IN (?) ..." | |
// BEFORE: baz := "1,2,3" | |
baz := int[]{1,2,3} | |
db.Raw(someQuery, baz).Find(&foo) | |
// Also tried replacing Find with Scan | |
fmt.Printf("%v", foo) | |
// RESULT: [{1,1}] | |
Result when I just run someQuery on its own in mysql: | |
test1 | test2 | |
1 | 1 | |
2 | 2 | |
3 | 3 | |
. | |
. | |
. | |
etc. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment