Published on

sqlalchemy json 字段常用函数

Authors
  • avatar
    Name
    Pony Ma
    Twitter

JSON_OVERLAPS

对比两个JSON, 有任何相同的键值对或数组元素,就返回True。

SELECT JSON_OVERLAPS("[1,3,5,7]", "[2,5,7]"); true
SELECT JSON_OVERLAPS('[4,5,6,7]', '6'); true
SELECT JSON_OVERLAPS('[4,5,"6",7]', '6'); false -- 字符串和数字不同
SELECT JSON_OVERLAPS('[[1,2],[3,4],5]', '[1,[2,3],[4,5]]'); false -- 数组和数组不同
SELECT JSON_OVERLAPS('{"a":1,"b":10,"d":10}', '{"c":1,"e":10,"f":1,"d":10}'); true