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

JSON_CONTAINS changes the JSON result

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.8.8, 10.5
    • 10.5, 10.6, 10.11, 11.4
    • JSON
    • Debian 10 - 10.8.8-MariaDB-1:10.8.8+maria~deb10-log - mariadb.org binary distribution

    Description

      JSON_CONTAINS somehow modifies the JSON_ARRAYAGG result, transforming an array to a bidimensional array:

      CREATE TABLE temp (v varchar(10), t int);
       
      INSERT INTO temp (v,t) VALUES ('A',1);
      INSERT INTO temp (v,t) VALUES ('B',1);
      INSERT INTO temp (v,t) VALUES ('B',2);
      INSERT INTO temp (v,t) VALUES ('C',2);
      INSERT INTO temp (v,t) VALUES ('C',3);
       
      SELECT JSON_ARRAYAGG(v) as array FROM temp GROUP BY t;
      

      +-----------+
      | array     |
      +-----------+
      | ["A","B"] |
      | ["B","C"] |
      | ["C"]     |
      +-----------+
      3 rows in set (0.010 sec)
      

      All perfect, until we try to make a JSON_CONTAINS:

      SELECT JSON_ARRAYAGG(v) as array FROM temp GROUP BY t HAVING JSON_CONTAINS(array, JSON_QUOTE('B'),'$');
      

      +-------------+
      | array       |
      +-------------+
      | [["A","B"]] |
      | [["B","C"]] |
      +-------------+
      2 rows in set (0.006 sec)
      

      The array column in the resulting rows is become a bidimensional array.
      This doesn't happen on MySQL 8.

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              madcowzz Marco Ripa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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