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

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 10.5.11
    • Fix Version/s: None
    • Component/s: JSON, Server
    • Labels:
      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

            Assignee:
            Unassigned
            Reporter:
            lukas.eder Lukas Eder
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Git Integration