Skip to content

JSONArrayQuery when contains a slice (in golang), which created extra parentheses #286

Open
@gwsee

Description

@gwsee

GORM Playground Link

go-gorm/playground#791

Description

the mysql column area type is json;

here is a simple code in golang;

var vals []interface{}
vals = append(vals, 1)
vals = append(vals, 2)
scopes = append(scopes, gen.Cond(datatypes.JSONArrayQuery("area").Contains(vals))...)

the sql build in mysql is
SELECT count(*) FROM kec WHERE JSON_CONTAINS (area, JSON_ARRAY((1,2))) ;(1241 - Operand should contain 1 column(s))

if there is none extra parentheses
SELECT count(*) FROM kec WHERE JSON_CONTAINS (area, JSON_ARRAY(1,2)) ; successful

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions