'When does JSON_CONTAINS return 1 with 3rd argument omitted?

There is a JSON_CONTAINS function in MySQL with 3 arguments. The documentation states that 3rd argument can be omitted and it will search in all paths then. Unfortunately, it doesn't work for me

SET @j = '{"a": 1, "b": 2, "c": {"d": 4}}';
SET @j2 = '1';
SELECT JSON_CONTAINS(@j, @j2, '$.a'); # returns 1
SELECT JSON_CONTAINS(@j, @j2); # returns 0

Can you provide an sensible example, when JSON_CONTAINS return 1 with 3rd argument omitted?

Is it possible to search in all nodes of JSON?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source