Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

PHPLIB-1273: Improve $switch syntax #62

Merged
merged 5 commits into from
Feb 2, 2024

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Feb 2, 2024

PHPLIB-1273

Instead of using object, there is now a dedicated case operator. In order to accommodate the different encoding for case, I added a flat_object encoding mechanism that doesn't wrap the parameter object in another object containing the operator name. Alternatively, we could create a separate encoder for case.

@alcaeus alcaeus requested a review from GromNaN February 2, 2024 10:33
@alcaeus alcaeus self-assigned this Feb 2, 2024
@@ -0,0 +1,21 @@
# $schema: ../schema.json
name: $case
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/switch/'
Copy link
Member

Choose a reason for hiding this comment

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

I see the interest of creating this "fake" operator for code generation. It should be consistent with OutputWindow this is the same need.

Could you create accumulator/outputWindow.yaml also?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do so in a separate PR: the current OutputWindow type contains additional validation logic that we can't represent through the config.

@alcaeus alcaeus force-pushed the phplib-1273-switch-syntax branch from 9804f17 to 745eef4 Compare February 2, 2024 12:47
@alcaeus alcaeus requested a review from GromNaN February 2, 2024 12:47
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

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

Switch stage is also in $convert, $isNumber and $toBool operator tests.

@alcaeus
Copy link
Member Author

alcaeus commented Feb 2, 2024

Switch stage is also in $convert, $isNumber and $toBool operator tests.

Updated

@alcaeus alcaeus requested a review from GromNaN February 2, 2024 13:18
@alcaeus alcaeus force-pushed the phplib-1273-switch-syntax branch from 0fef6aa to a80cdf7 Compare February 2, 2024 13:21
@alcaeus alcaeus merged commit ceac70d into mongodb:0.1 Feb 2, 2024
@alcaeus alcaeus deleted the phplib-1273-switch-syntax branch February 2, 2024 14:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants