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

Unexpected behavior with negative zero (-0) in JSON Path

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.9(EOL)
    • 10.9.0
    • JSON

    Description

      Test:

      SET @json='{ "x": [0,1]}';
      SELECT JSON_VALUE(@json,'$.x[last]');
      SELECT JSON_VALUE(@json,'$.x[last-0]');
      SELECT JSON_VALUE(@json,'$.x[-0]');
      SELECT JSON_VALUE(@json,'$.x[0]');
      

      Expected result:
      Expected that 'last' and 'last-0' give the same result

      SELECT JSON_VALUE(@json,'$.x[last]');
      JSON_VALUE(@json,'$.x[last]')
      1
      SELECT JSON_VALUE(@json,'$.x[last-0]');
      JSON_VALUE(@json,'$.x[last-0]')
      1
      

      and index '0' and '-0' too:

      SELECT JSON_VALUE(@json,'$.x[-0]');
      JSON_VALUE(@json,'$.x[-0]')
      0
      SELECT JSON_VALUE(@json,'$.x[0]');
      JSON_VALUE(@json,'$.x[0]')
      0
      

      but Actual result:

      SET @json='{ "x": [0,1]}';
      SELECT JSON_VALUE(@json,'$.x[last]');
      JSON_VALUE(@json,'$.x[last]')
      1
      SELECT JSON_VALUE(@json,'$.x[last-0]');
      JSON_VALUE(@json,'$.x[last-0]')
      NULL
      SELECT JSON_VALUE(@json,'$.x[-0]');
      JSON_VALUE(@json,'$.x[-0]')
      NULL
      SELECT JSON_VALUE(@json,'$.x[0]');
      JSON_VALUE(@json,'$.x[0]')
      0
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              lstartseva Lena Startseva
              Votes:
              0 Vote for this issue
              Watchers:
              3 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.