datatypes icon indicating copy to clipboard operation
datatypes copied to clipboard

数字数组查询不对劲

Open liyuan1125 opened this issue 3 years ago • 2 comments

数据是这样的

["330100", "330200", "330300", "330400", "330500", "330600", "330700", "330800", "330900", "331000", "331100"]

db.Table("table_name").Where(datatypes.JSONQuery("area_code").HasKey("330100")).Find(&rows)

错误:

Invalid JSON path expression. The error is around character position 8.

liyuan1125 avatar Dec 22 '22 23:12 liyuan1125

可以试试这么查询,db.Table("table_name").Where(datatypes.JSONArrayQuery("area_code").Contains("330100")).Find(&rows)

Jeffreeey avatar Feb 09 '23 09:02 Jeffreeey

same problem how to query this in postgresql ?

select * from table where area_code::jsonb @>'[330100]'

tiptok avatar Sep 20 '23 06:09 tiptok