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

Comparison of JSON_EXTRACT result differs with Mysql

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2.5
    • Fix Version/s: 10.2.8
    • Component/s: JSON
    • Labels:
    • Environment:
      Debian

      Description

      There seems to be different behaviour when comparing the result of JSON_EXTRACT in MySql 5.7 and Mariadb 10.2.5.

      In MySql the following query will result in true, but in mariadb this results in 0.

      select JSON_EXTRACT('{"name":"value"}', '$.name') = 'value';
      

      To fix this I tried to just quote the value to compare and it works in mariadb (result: 1) but not in MySql (result: 0).

      select JSON_EXTRACT('{"name":"value"}', '$.name') = JSON_QUOTE('value');
      

      It's also an issue with boolean values:

      SET @str = '{\"asdf\":true}';
      SET @path = "$.\"asdf\"";
      select @str, @path, JSON_EXTRACT(@str, @path) = 'true'; -- mariadb
      select @str, @path, JSON_EXTRACT(@str, @path) = true; -- mysql
      

        Attachments

          Activity

            People

            Assignee:
            holyfoot Alexey Botchkov
            Reporter:
            apreiml Armin Preiml
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: