You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would like to know the methods to generate a JSON_CONTAINS SQL query using SQLBuilder
// Build implements clause.Expression
func (json *JSONArrayExpression) Build(builder clause.Builder) {
if stmt, ok := builder.(*gorm.Statement); ok {
switch stmt.Dialector.Name() {
case "mysql":
builder.WriteString("JSON_CONTAINS (" + stmt.Quote(json.column) + ", JSON_ARRAY(")
builder.AddVar(stmt, json.equalsValue)
builder.WriteString("))")
}
}
}
datatypes.JSONArrayExpression append a JSON_ARRAY('') string in Build method, and this does not support slice value, I finally found a solution to this problem.
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: