go-gorm / go-gorm/datatypes

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

Open
#286 0 comments 0 reactions 1 assignee Claimed by @jinzhu View on GitHub
Dominant language
Go
Stars
831
Forks
124
PR merge metrics
No merged PRs in 30d

Description

## GORM Playground Link

https://github.com/go-gorm/playground/pull/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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.