Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cosmos: translate IN with parameter values again, and possibly other Cosmos-specific patterns #31051

Closed
roji opened this issue Jun 7, 2023 · 1 comment
Labels
closed-no-further-action The issue is closed and no further action is planned.

Comments

@roji
Copy link
Member

roji commented Jun 7, 2023

As part of #31046, NewArrayExpression no longer gets client-evaluated to a single array parameter; this allows us to translate e.g. new[] { i, j } to IN (@i, @j). Full translation support for NewArrayExpression has been implemented in relational (as VALUES (...), which gets transformed to IN if Contains is composed on top); but Cosmos support hasn't been done.

As a result, Cosmos queries which include parameters fail translation; see test Array_of_parameters_Contains_OrElse_comparison_with_constant_gets_combined_to_one_in:

var prm1 = "ALFKI";
var prm2 = "ANATR";

return AssertQuery(
    async,
    ss => ss.Set<Customer>().Where(c => new[] { prm1, prm2 }.Contains(c.CustomerID) || c.CustomerID == "ANTON"),
    entryCount: 3);

We can implement support for this in the Cosmos query pipeline, and there's some potential for Cosmos-specific translations around the area as well. In the meantime, the workaround is to extract the inline array:

var array = new[] { "ALFKI", "ANATR" };

return AssertQuery(
    async,
    ss => ss.Set<Customer>().Where(c => array.Contains(c.CustomerID) || c.CustomerID == "ANTON"),
    entryCount: 3);
@roji roji added type-enhancement area-query area-cosmos closed-no-further-action The issue is closed and no further action is planned. labels Jun 7, 2023
@roji
Copy link
Member Author

roji commented Jun 13, 2023

Closing as support for the NewArrayExpression was implemented in Cosmos as part of #31046 to prevent the breaking change.

@roji roji closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
closed-no-further-action The issue is closed and no further action is planned.
Projects
None yet
Development

No branches or pull requests

2 participants