Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why can't find the function JSONArrayQuery definition? #185

Open
dablelv opened this issue Feb 3, 2023 · 8 comments
Open

Why can't find the function JSONArrayQuery definition? #185

dablelv opened this issue Feb 3, 2023 · 8 comments
Assignees

Comments

@dablelv
Copy link

dablelv commented Feb 3, 2023

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 中,但是我在源代码中没有找到对应的定义,且无法使用,这是为什么?

@tzq0301
Copy link

tzq0301 commented Feb 3, 2023

+1

@tzq0301
Copy link

tzq0301 commented Feb 3, 2023

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

@tzq0301
Copy link

tzq0301 commented Feb 3, 2023

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 😁

@dablelv
Copy link
Author

dablelv commented Feb 3, 2023

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

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

@tzq0301
Copy link

tzq0301 commented Feb 3, 2023

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

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

@dablelv
Copy link
Author

dablelv commented Feb 3, 2023

没有任何一个 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))

@tzq0301
Copy link

tzq0301 commented Feb 3, 2023

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

@alingse
Copy link
Contributor

alingse commented Apr 12, 2023

v1.2.0 有了 https://github.com/go-gorm/datatypes/tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants