• Rucha Deodhar's avatar
    MDEV-27677: Implement JSON_OVERLAPS() · a653dde2
    Rucha Deodhar authored
    1) When at least one of the two json documents is of scalar type:
         1.a) If value and json document both are scalar, then return true
              if they have same type and value.
         1.b) If json document is scalar but other is array (or vice versa),
              then return true if array has at least one element of same type
              and value as scalar.
         1.c) If one is scalar and other is object, then return false because
              it can't be compared.
    
      2) When both arguments are of non-scalar type and below conditons
          are satisfied then return true:
          2.a) When both arguments are arrays:
               Iterate over the value and json document. If there exists at
               least one element in other array of same type and value as
               that of element in value.
          2.b) If both arguments are objects:
               Iterate over value and json document and if there exists at least
               one key-value pair common between two objects.
          2.c) If either of json document or value is array and other is object:
               Iterate over the array, if an element of type object is found,
               then compare it with the object (which is the other arguemnt).
               If the entire object matches i.e all they key value pairs match.
    a653dde2
func_json.test 35.9 KB