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(arg2, JSON_QUOTE(arg1));
      

      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

              alice Alice Sherepa
              serg Sergei Golubchik
              Daniel Black Daniel Black
              Daniel Black Daniel Black
              Alice Sherepa Alice Sherepa
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 0d
                  0d
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 2d 47m
                  2d 47m

                  Git Integration

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