Repository navigation
Python: Keep null fields out of Azure DocumentDB membership filters - #8654
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit intoSep 23, 2026
Conversation
Portable in/not_in membership never matches a null field, but the
DocumentDB filter compiler kept None in the $in operands behind an
$exists guard, so Filter("x", "in", [None, "a"]) also returned
documents whose field is null. Drop None operands like the MongoDB,
Redis and Postgres connectors do.
Fixes microsoft#8653
Saquib Jawed (saquibjawedbit)
temporarily deployed
to
github-app-auth
September 22, 2026 17:09 — with
GitHub Actions
Inactive
Saquib Jawed (saquibjawedbit)
temporarily deployed
to
github-app-auth
September 22, 2026 17:10 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
enabled auto-merge
September 23, 2026 08:14
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Sep 23, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
Saquib Jawed (@saquibjawedbit) Reviewed the current head; no blocking findings.
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Portable
in/not_infilters never match a null field. That is how the core reference evaluator behaves (_evaluate_filter, used byInMemoryCollection), and the Postgres, Redis, MongoDB and Azure Cosmos DB connectors all follow it. The Azure DocumentDB connector keptNonein the$inoperands and added only an$existsguard, soFilter("category", "in", [None, "a"])also returned documents whosecategoryis null, andFilter("category", "in", [None])returned every null record instead of none. The same filter therefore returned different records depending on the store.Description & Review Guide
_FilterCompiler._prepare_filter_conditiondropsNoneoperands forin/not_in, as the MongoDB and Redis connectors already do. Aninwith only non-null operands is a plain$in, which cannot match null or missing fields.not_inkeeps its existing$exists+$ne: nullguards, so its output is unchanged apart fromNoneno longer appearing in$nin. A regression test coversinandnot_inwith and without other operands.Noneoperands compile exactly as before.in/not_inbranch in_prepare_filter_condition.Noneis the only input_prepare_filter_operandmaps toNone, so filtering it before preparation removes every null operand.Related Issue
Fixes #8653
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.