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

Wrong result (phantom array value) on JSON_EXTRACT

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2
    • Fix Version/s: 10.2.8
    • Component/s: JSON
    • Labels:
      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

            Assignee:
            holyfoot Alexey Botchkov
            Reporter:
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: