go-gorm/datatypes

Why can't find the function JSONArrayQuery definition?

dablelv opened this issue · 8 comments

The array query function datatypes.JSONArrayQuery appears in the README, but I can't find it's definition in source codes and can't be used? Why?

数组查找函数 JSONArrayQuery 出现在 README 中,但是我在源代码中没有找到对应的定义,且无法使用,这是为什么?

+1

Found in json.go, but unable to use
image
image

I think this problem maybe caused by the tag of this repository? Can you help update the tag v1.1.0 plz @jinzhu? thx a lot 😁

Found in json.go, but unable to use image image

哪一个 tag 可以找到其定义?

没有任何一个 tag 可以找到该定义,这好像是最近的 feature,还没被打 tag

@dablelv 试试 go get gorm.io/datatypes@c43177d3cf8c975e7eb504b76f23150e3c01d662

没有任何一个 tag 可以找到该定义,这好像是最近的 feature,还没被打 tag

@dablelv 试试 go get gorm.io/datatypes@c43177d3cf8c975e7eb504b76f23150e3c01d662

明白了,最新的代码还没有打 tag。

不过我使用原生 sql 作为 GORM 的内联条件可以达到同样的目的:判断数组中是否包含某值。

db.Find(&rows, fmt.Sprintf(`json_contains(YOUR_COLUMN,'"%v"')`, YOUR_STR_VALUE))

其实还是希望能支持能更多的 sql 数据库,目前好像只支持 mysql,我们用 sqlite 做单测的时候完全没法用