-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL builder fro JSON_CONTAINS to search multiple values in a JSON array #139
Comments
It's very important, and how we can application IN statement that in SQL with JSON query? |
Then use the code to support custom conditions. And this cond implements
|
I created new type that implemented the gorm.Valuer interface import (
"code.byted.org/gopkg/lang/slices"
"context"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"strings"
)
type SliceOfString []string
func (s SliceOfString) GormValue(context.Context, *gorm.DB) clause.Expr {
return clause.Expr{SQL: strings.Join(slices.MapString(s, func(s string) string { return "'" + s + "'" }), ", ")}
} and used the following condition code var list SliceOfString
.
.
.
Where(gen.Cond(datatypes.JSONArrayQuery("column-name").Contains(list))...) |
Your Question
Is there a way to build an SQL query that searches multiple-values (not multiple keys) in a JSON array?
Or:
The document you expected this should be explained
https://gorm.io/docs/data_types.html
Expected answer
Would like to know the methods to generate a JSON_CONTAINS SQL query using SQLBuilder
The text was updated successfully, but these errors were encountered: