go-gorm/datatypes

数字数组查询不对劲

liyuan1125 opened this issue · 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.

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

same problem
how to query this in postgresql ?

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