Skip to content

Commit 4fe602c

Browse files
author
dushixiang
authored
JSONArrayExpression support sqlite and postgres (#252)
1 parent 4f5cbfd commit 4fe602c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

json.go

+8
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,14 @@ func (json *JSONArrayExpression) Build(builder clause.Builder) {
467467
builder.WriteString("JSON_CONTAINS (" + stmt.Quote(json.column) + ", JSON_ARRAY(")
468468
builder.AddVar(stmt, json.equalsValue)
469469
builder.WriteString("))")
470+
case "sqlite":
471+
builder.WriteString("exists(SELECT 1 FROM json_each(" + stmt.Quote(json.column) + ") WHERE value = ")
472+
builder.AddVar(stmt, json.equalsValue)
473+
builder.WriteString(")")
474+
case "postgres":
475+
builder.WriteString(stmt.Quote(json.column))
476+
builder.WriteString(" ? ")
477+
builder.AddVar(stmt, json.equalsValue)
470478
}
471479
}
472480
}

0 commit comments

Comments
 (0)