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

JSON_TYPE doesn't work correctly

    XMLWordPrintable

Details

    • Bug
    • Status: Stalled (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.2(EOL), 10.3(EOL)
    • 10.4(EOL)
    • JSON
    • Tried on Ubuntu

    Description

      The JSON_TYPE works well with arguments generated by the JSON_QUERY funtions and correctly detect the OBJECT and ARRAY types.
      When the argument originates from the JSON_VALUE function, it detects onyl INTEGERs correctly.
      Decimals are detected as DOUBLE.
      Strings are detected as NULL (no type) and strings beginning with an integer (like "23hjk") number are detected as INTEGER; if they begin with a decimal (like "3.234dfg") they are detected as DOUBLE.

      SELECT
      	JSON_VALID(t.json),
      	JSON_TYPE(JSON_QUERY(t.json,'$.b')),
      	JSON_TYPE(JSON_QUERY(t.json,'$.b.gh')),
      	JSON_TYPE(JSON_VALUE(t.json,'$.b.ab')),
      	JSON_TYPE(JSON_VALUE(t.json,'$.b.cd')),
      	JSON_TYPE(JSON_VALUE(t.json,'$.b.ef')),
      	JSON_TYPE(JSON_VALUE(t.json,'$.b.gh[0].ghi')),
      	JSON_TYPE(JSON_VALUE(t.json,'$.b.gh[1].jkl'))
      FROM
      	(SELECT '{"a": "abc", "b": {"ab": "xyz5", "cd": "1xvz", "ef": "321", "gh": [{"ghi": "1.234"}, {"jkl": "334.2qrt"}]}}' AS json) AS t;
      

      Actually these statements would be sufficient to reproduce:

      select JSON_TYPE('321');
      show warnings;
       
      select JSON_TYPE('abc');
      show warnings;
       
      select JSON_TYPE('123abc');
      show warnings;
       
      select JSON_TYPE('12.3abc');
      show warnings;
      

      Attachments

        Issue Links

          Activity

            People

              rucha174 Rucha Deodhar
              nicolamarangoni Nicola Marangoni
              Votes:
              0 Vote for this issue
              Watchers:
              5 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.