Skip to content

feat(firestore): Add logical expressions#7589

Open
milaGGL wants to merge 10 commits intomainfrom
mila/expressions-logical
Open

feat(firestore): Add logical expressions#7589
milaGGL wants to merge 10 commits intomainfrom
mila/expressions-logical

Conversation

@milaGGL
Copy link
Contributor

@milaGGL milaGGL commented Mar 11, 2026

Add new logical expressions nor and switchOn.

Ported from firebase/firebase-js-sdk#9702

@milaGGL milaGGL requested a review from a team as a code owner March 11, 2026 19:19
@product-auto-label product-auto-label bot added the api: firestore Issues related to the Firestore API. label Mar 11, 2026
@quirogas quirogas added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 12, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 12, 2026
@milaGGL milaGGL added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 12, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 12, 2026
@milaGGL milaGGL added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 16, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 16, 2026

/**
* @beta
* Creates an expression that evaluates to the result corresponding to the first true condition.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if the result types must all be the same?

Can we do something like

switchOn(
  equal(field("status"), 1), constant("Active") // string
  equal(field("status"), 2), constant(0) // int
)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good question. yes we can, each switch cases are independent from each other, so the type is not required to be the same. So we can do sth like

switchOn(
  equal(field("number"), "one"), constant(1),
  equal(field("number"), "two"), constant(2),
  constant("not a number")
)

Do you want me to add a test case for it?

@quirogas quirogas added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 16, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the Firestore API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants