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

JSON_EXTRACT surprising auto-wrap

    XMLWordPrintable

Details

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

    Description

      The sequence of statements below yields a strange result, in particular it is also different from previous MariaDB versions (namely, 10.8.3).

      I believe the wildcard member accessory should always apply an auto-wrap, but the but I get one row wrapped, the second one not. I would expect both being wrapped, thus instead of "20" I'd expect "[20]".

      MariaDB 5.5.5-10.9.2-MariaDB>  CREATE TABLE demo_json_z2o1 (
          ->      id NUMERIC NOT NULL,
          ->      j VARCHAR(255)
          ->  );
      Query OK, 0 rows affected (0.00 sec)
       
      MariaDB 5.5.5-10.9.2-MariaDB> INSERT INTO demo_json_z2o1 (id, j) VALUES (1,'{"a": 10}');
      Query OK, 1 row affected (0.00 sec)
       
      MariaDB 5.5.5-10.9.2-MariaDB> INSERT INTO demo_json_z2o1 (id, j) VALUES (2,'{"b": 20}');
      Query OK, 1 row affected (0.00 sec)
       
      MariaDB 5.5.5-10.9.2-MariaDB>  SELECT id
          ->       , JSON_EXTRACT(j, '$.*') val
          ->    FROM demo_json_z2o1
          ->   ORDER BY id;
      +----+------+
      | id | val  |
      +----+------+
      |  1 | [10] |
      |  2 | 20   |
      +----+------+
      2 rows in set (0.00 sec)
       
      MariaDB 5.5.5-10.9.2-MariaDB>

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            Markus Winand Markus Winand
            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.