Skip to content

[Bug] (json) incorrect results of json_contains #59692

@lucienlgl

Description

@lucienlgl

Search before asking

  • I had searched in the issues and found no similar issues.

Version

2.1.8.3

What's Wrong?

When I was using version 2.1.8, I encountered a situation where the json_contains function returned incorrect results.

Here is my test cases:

  1. SELECT JSON_CONTAINS('{}', '{"key": "key1", "value": "value1"}');
    --- return: 1
  2. SELECT JSON_CONTAINS('{"2":"2","1":"1","3":"3"}', '{"key": "value"}');
    --- return: 1
  3. SELECT * FROM table WHERE JSON_CONTAINS('["1","2","3"]', '"1"') and JSON_CONTAINS('["1","2","3"]', '"2"') limit 100;
    --- return: [HY000][1105] errCode = 2, detailMessage = Unexpected exception: Not support comparison between JSONB literals

I found a similar issue, but I'm not sure if it's the same problem: #53291.
I would like to confirm if this is the same problem? If so, is there any plan to fix version 2.1.x ?

What You Expected?

  1. SELECT JSON_CONTAINS('{}', '{"key": "key1", "value": "value1"}');
    --- return: 0
  2. SELECT JSON_CONTAINS('{"2":"2","1":"1","3":"3"}', '{"key": "value"}');
    --- return: 0
  3. SELECT * FROM table WHERE JSON_CONTAINS('["1","2","3"]', '"1"') and JSON_CONTAINS('["1","2","3"]', '"2"') limit 100;
    --- return: successfully executed and returned data

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions