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

JSON_CONTAINS changes the JSON result

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.8.8
    • 10.11, 11.0, 11.1, 11.2
    • 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

        Activity

          People

            rucha174 Rucha Deodhar
            madcowzz Marco Ripa
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.