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

MEMBER OF json operator

    XMLWordPrintable

Details

    Description

      Implement MEMBER OF operator for MySQL compatibility.
      Used as

      mysql> SELECT 17 MEMBER OF('[23, "abc", 17, "ab", 10]');
      +-------------------------------------------+
      | 17 MEMBER OF('[23, "abc", 17, "ab", 10]') |
      +-------------------------------------------+
      |                                         1 |
      +-------------------------------------------+
       
      mysql> SELECT "17" MEMBER OF('[23, "abc", 17, "ab", 10]');
      +---------------------------------------------+
      | "17" MEMBER OF('[23, "abc", 17, "ab", 10]') |
      +---------------------------------------------+
      |                                           0 |
      +---------------------------------------------+

      Can probably be implemented as

      SELECT JSON_CONTAINS(arg1, JSON_QUOTE(arg2));
      

      but JSON_QUOTE needs to be extended to convert non-string arguments. Now it's

      MariaDB [test]> select json_quote(17), json_quote('17'), json_quote(null);
      +----------------+------------------+------------------+
      | json_quote(17) | json_quote('17') | json_quote(null) |
      +----------------+------------------+------------------+
      | NULL           | "17"             | NULL             |
      +----------------+------------------+------------------+
      1 row in set (0.001 sec)
      

      must be

      MariaDB [test]> select json_quote(17), json_quote('17'), json_quote(null);
      +----------------+------------------+------------------+
      | json_quote(17) | json_quote('17') | json_quote(null) |
      +----------------+------------------+------------------+
      | 17             | "17"             | null             |
      +----------------+------------------+------------------+
      1 row in set (0.001 sec)
      

      that is, numbers and null should be converted to json numbers and json null.

      Attachments

        Issue Links

          Activity

            People

              danblack Daniel Black
              serg Sergei Golubchik
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.