Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-28071

JSON_EXISTS returns always 1 if it is used range notation for json path

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • 10.9.1
    • JSON
    • None

    Description

      Test: (value in range 3 to 4 is absent)

      SET @json= '[
                   [1, {"key1": "value1"}, 3],
                   [false, 5, 6],
                   [7, 8, [9, {"key2": 2}, 11]],
                   [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
                   [19, 20],
                   21, 22
                  ]';
      SELECT JSON_EXISTS(@json, '$[2][2][3]');
      SELECT JSON_EXISTS(@json, '$[2][2][4]');
      SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');
      

      Expected result:

      SET @json= '[
                   [1, {"key1": "value1"}, 3],
                   [false, 5, 6],
                   [7, 8, [9, {"key2": 2}, 11]],
                   [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
                   [19, 20],
                   21, 22
                  ]';
      SELECT JSON_EXISTS(@json, '$[2][2][3]');
      JSON_EXISTS(@json, '$[2][2][3]')
      0
      SELECT JSON_EXISTS(@json, '$[2][2][4]');
      JSON_EXISTS(@json, '$[2][2][4]')
      0
      SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');
      JSON_EXISTS(@json, '$[2][2][3 to 4]')
      0
      

      Actual result:

      SET @json= '[
                   [1, {"key1": "value1"}, 3],
                   [false, 5, 6],
                   [7, 8, [9, {"key2": 2}, 11]],
                   [15, 1.34, [14], ["string1", [16, {"key1":[1,2,3,[4,5,6]]}, 18]]],
                   [19, 20],
                   21, 22
                  ]';
      SELECT JSON_EXISTS(@json, '$[2][2][3]');
      JSON_EXISTS(@json, '$[2][2][3]')
      0
      SELECT JSON_EXISTS(@json, '$[2][2][4]');
      JSON_EXISTS(@json, '$[2][2][4]')
      0
      SELECT JSON_EXISTS(@json, '$[2][2][3 to 4]');
      JSON_EXISTS(@json, '$[2][2][3 to 4]')
      1
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.