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

Comparison of JSON_EXTRACT result differs with Mysql

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2.5
    • 10.2.8
    • JSON
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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