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

Wrong result (phantom array value) on JSON_EXTRACT

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2(EOL)
    • 10.2.8
    • JSON
    • None

    Description

      MariaDB 10.2

      MariaDB [test]> SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*].*' );
      +-------------------------------------------+
      | JSON_EXTRACT( '{"foo":"bar"}', '$[*].*' ) |
      +-------------------------------------------+
      | ["bar"]                                   |
      +-------------------------------------------+
      1 row in set (0.00 sec)
      

      I think it is incorrect and there should be NULL, since $[*] is supposed to represent array values, but there is no array in the JSON text.
      It's also inconsistent with this result:

      MariaDB 10.2

      MariaDB [test]> SELECT JSON_EXTRACT( '{"foo":"bar"}', '$[*]' );
      +-----------------------------------------+
      | JSON_EXTRACT( '{"foo":"bar"}', '$[*]' ) |
      +-----------------------------------------+
      | NULL                                    |
      +-----------------------------------------+
      1 row in set (0.00 sec)
      

      MySQL returns NULL for both queries, however in this case I don't want to use it as a baseline, because its behavior with these pseudo-arrays is even more inconsistent. Please just use documentation, standards and common sense to determine what the correct result should be.

      Attachments

        Activity

          People

            holyfoot Alexey Botchkov
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.