Use JSON_CONTAINS() to translate JSON array containment
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
According to the [`JSON_CONTAINS()` docs](https://learn.microsoft.com/en-us/sql/t-sql/functions/json-contains-transact-sql?view=sql-server-ver17):
> A JSON array search value is contained in a target array if and only if every element in the search array is contained in some element of the target array.
This means we should be able to use it to translate `jsonArray1.subset.All(s => jsonArray2.Contains(s))` (array containment).
However, at the time of writing, the `json` type isn't supported as search value (see limitations). Also keep in mind the problematic null behavior of JSON_CONTAINS(), i.e. specifically check what happens if the contained array has nulls.
Contributor guide
Assessment
This issue has not been assessed yet.