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

Embedding JSON from derived tables quotes the JSON, unlike from scalar subqueries

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5.11
    • None
    • JSON, Server
    • None

    Description

      The following query wraps JSON from a derived table in more JSON:

      select json_array(`v1`) from (select json_array(1) as `v1`) as `t`
      

      This results in undesirable output:

      ["[1]"]
      

      It doesn't happen with scalar subqueries:

      select json_array((select json_array(1) as `v1`))
      

      Or with the usual laborious workaround for such problems:

      select json_array(json_merge_preserve('[]', `v1`))
      from (select json_array(1) as `v1`) as `t`
      

      Both resulting in the expected output

      [[1]]
      

      For comparison, MySQL 8.0.22 doesn't behave this way.

      Attachments

        Activity

          People

            Unassigned Unassigned
            lukas.eder Lukas Eder
            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.