I want to use sqlboiler with a variable which come from c.Query() in gin framework, but sqlboiler returns ERROR: sql: no rows in result set. Are there any ways to pass the variable?
Here is my sample code:
func getUser(c *gin.Context){
name := c.Query("name")
/* some db setting */
user, err := models.Users(
qm.WhereIn("name in ?", name),
).One(ctx, db)
}
I know that this works:
func getUser(){
name := "John"
/* some db setting */
user, err := models.Users(
qm.WhereIn("name in ?", name),
).One(ctx, db)
}
I noticed that the reason why sql: no rows in result set occurs is failure in my get request.
I called request in next format: http://localhost:8080/api/user?name="John". However, right request format is here: http://localhost:8080/api/user?name=John.
Just, I remove double quotes, and sqlboiler can search John, not "John".