* bson_dollar_nin implements the $nin functionality * in the runtime. This traverses the document based on * filter dot-notation syntax and for all possible values, checks * that at least one does not match the query value presented. * Note: per $nin requirements, documents that don't have the field * are also considered to be $nin. */
| 1599 | * are also considered to be $nin. |
| 1600 | */ |
| 1601 | Datum |
| 1602 | bson_dollar_nin(PG_FUNCTION_ARGS) |
| 1603 | { |
| 1604 | pgbson *document = PG_GETARG_PGBSON(0); |
| 1605 | bson_iter_t documentIterator; |
| 1606 | TraverseInValidateState state = { 0 }; |
| 1607 | |
| 1608 | pgbsonelement filterElement = { 0 }; |
| 1609 | PopulateDollarInValidationState(fcinfo, &state, &filterElement, false); |
| 1610 | |
| 1611 | PgbsonInitIterator(document, &documentIterator); |
| 1612 | |
| 1613 | TraverseBson(&documentIterator, filterElement.path, &state.traverseState, |
| 1614 | &CompareExecutionFuncs); |
| 1615 | |
| 1616 | if (state.hasNull) |
| 1617 | { |
| 1618 | /* If any element in the input is null and the target path cannot be found in the document, we'll not choose that document. */ |
| 1619 | PG_RETURN_BOOL(state.traverseState.compareResult == CompareResult_Mismatch); |
| 1620 | } |
| 1621 | else |
| 1622 | { |
| 1623 | PG_RETURN_BOOL(state.traverseState.compareResult != CompareResult_Match); |
| 1624 | } |
| 1625 | } |
| 1626 | |
| 1627 | |
| 1628 | /* |
nothing calls this directly
no test coverage detected