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

JSON_KEYS returns duplicate keys twice

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.2.5
    • 10.2.8
    • JSON
    • None
    • Linux CentOS 6.5

    Description

      When there are multiple attributes in a JSON object with the same name, which is allowed but discouraged in JSON, JSON_KEYS returns one entry for each duplicate:

      MySQL [test]> select JSON_KEYS('{"c1": "value 1", "c1": "value 2"}');
      +-------------------------------------------------+
      | JSON_KEYS('{"c1": "value 1", "c1": "value 2"}') |
      +-------------------------------------------------+
      | ["c1", "c1"]                                    |
      +-------------------------------------------------+
      

      MySQL 5.7 returns just the single key:

      MySQL [test]> select JSON_KEYS('{"c1": "value 1", "c1": "value 2"}');
      +-------------------------------------------------+
      | JSON_KEYS('{"c1": "value 1", "c1": "value 2"}') |
      +-------------------------------------------------+
      | ["c1"]                                          |
      +-------------------------------------------------+
      

      Multiple values for a single key are discouraged, but I think MySQL has the correct behavior as the JSON_KEYS function should return an array of the keys, and although "c1" in the example above exists twice in the object, it is the same key.

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              karlsson Anders Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 1d
                  1d

                  Git Integration

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