mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-13306 JSON_CONTAINS returns wrong value.
The 'value' state should be saved to be compared against the next array item.
This commit is contained in:
parent
08c493c62a
commit
1f6ada8da8
3 changed files with 11 additions and 0 deletions
|
@ -152,6 +152,9 @@ json_contains('[{"abc":"def", "def":"abc"}]', '["foo","bar"]')
|
|||
select json_contains('[{"abc":"def", "def":"abc"}, "bar"]', '["bar", {}]');
|
||||
json_contains('[{"abc":"def", "def":"abc"}, "bar"]', '["bar", {}]')
|
||||
1
|
||||
select json_contains('[{"a":"b"},{"c":"d"}]','{"c":"d"}');
|
||||
json_contains('[{"a":"b"},{"c":"d"}]','{"c":"d"}')
|
||||
1
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
|
||||
json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]")
|
||||
1
|
||||
|
|
|
@ -56,6 +56,7 @@ select json_contains('[1, {"a":1}]', '{}');
|
|||
select json_contains('[1, {"a":1}]', '{"a":1}');
|
||||
select json_contains('[{"abc":"def", "def":"abc"}]', '["foo","bar"]');
|
||||
select json_contains('[{"abc":"def", "def":"abc"}, "bar"]', '["bar", {}]');
|
||||
select json_contains('[{"a":"b"},{"c":"d"}]','{"c":"d"}');
|
||||
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[1]");
|
||||
select json_contains_path('{"key1":1, "key2":[2,3]}', "oNE", "$.key2[10]");
|
||||
|
|
|
@ -1011,6 +1011,8 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
|
|||
case JSON_VALUE_ARRAY:
|
||||
if (value->value_type != JSON_VALUE_ARRAY)
|
||||
{
|
||||
loc_js= *value;
|
||||
set_js= FALSE;
|
||||
while (json_scan_next(js) == 0 && js->state != JST_ARRAY_END)
|
||||
{
|
||||
int c_level, v_scalar;
|
||||
|
@ -1021,6 +1023,11 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
|
|||
if (!(v_scalar= json_value_scalar(js)))
|
||||
c_level= json_get_level(js);
|
||||
|
||||
if (set_js)
|
||||
*value= loc_js;
|
||||
else
|
||||
set_js= TRUE;
|
||||
|
||||
if (check_contains(js, value))
|
||||
{
|
||||
if (json_skip_level(js))
|
||||
|
|
Loading…
Reference in a new issue