ArrayOverlaps return true if there is even one element common between the left and right arrays.
( ctx context.Context, cmpCtx CompareContext, array, other *DArray, )
| 385 | // ArrayOverlaps return true if there is even one element |
| 386 | // common between the left and right arrays. |
| 387 | func ArrayOverlaps( |
| 388 | ctx context.Context, cmpCtx CompareContext, array, other *DArray, |
| 389 | ) (*DBool, error) { |
| 390 | if !array.ParamTyp.Equivalent(other.ParamTyp) { |
| 391 | return nil, pgerror.New(pgcode.DatatypeMismatch, "cannot compare arrays with different element types") |
| 392 | } |
| 393 | for _, needle := range array.Array { |
| 394 | // Nulls don't compare to each other in && syntax. |
| 395 | if needle == DNull { |
| 396 | continue |
| 397 | } |
| 398 | for _, hay := range other.Array { |
| 399 | if cmp, err := needle.Compare(ctx, cmpCtx, hay); err != nil { |
| 400 | return DBoolFalse, err |
| 401 | } else if cmp == 0 { |
| 402 | return DBoolTrue, nil |
| 403 | } |
| 404 | } |
| 405 | } |
| 406 | return DBoolFalse, nil |
| 407 | } |
| 408 | |
| 409 | // JSONExistsAny return true if any value in dArray is exist in the json |
| 410 | func JSONExistsAny(json DJSON, dArray *DArray) (*DBool, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…