Skip to content

Conversation

@WaVEV
Copy link
Collaborator

@WaVEV WaVEV commented Nov 3, 2025

Need to add more tests.

@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch 2 times, most recently from 7d6386e to b90d50e Compare November 3, 2025 21:24
@WaVEV WaVEV force-pushed the INTPYTHON-713-Push-conditions-into-lookup branch from 184d5e6 to 73bfed5 Compare November 9, 2025 21:02
@Jibola Jibola changed the title Push conditions into lookup when is possible. INTPYTHON-793: Push conditions into lookup when is possible. Nov 11, 2025
combinator_pipeline.append({"$unset": "_id"})
return combinator_pipeline

def _get_pushable_conditions(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments please

Comment on lines +12 to +29
def _normalize_query(obj):
if isinstance(obj, dict):
normalized = {}
for k, v in obj.items():
if k in MongoTestCaseMixin.COMMUTATIVE_OPERATORS and isinstance(v, list):
# Only sort for commutative operators
normalized[k] = sorted(
(MongoTestCaseMixin._normalize_query(i) for i in v), key=lambda x: str(x)
)
else:
normalized[k] = MongoTestCaseMixin._normalize_query(v)
return normalized

if isinstance(obj, list):
# Lists not under commutative ops keep their order
return [MongoTestCaseMixin._normalize_query(i) for i in obj]

return obj
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a docstring. It looks like there's some sorting happening, perhaps because the generated query isn't deterministic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants