Skip to content

Update exception message for Cosmos subquery pushdown #30849

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 30 additions & 27 deletions src/EFCore.Cosmos/Properties/CosmosStrings.resx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -217,6 +217,9 @@
<data name="NoReadItemQueryString" xml:space="preserve">
<value>There is no string-based representation of this query as it's executed using 'ReadItemQueryAsync({resourceId}, {partitionKey})'.</value>
</data>
<data name="NoSubqueryPushdown" xml:space="preserve">
<value>Azure Cosmos DB does not have an appropriate subquery for this translation.</value>
</data>
<data name="NullTypeMappingInSqlTree" xml:space="preserve">
<value>The expression '{sqlExpression}' in the SQL tree does not have a type mapping assigned.</value>
</data>
Expand Down
15 changes: 12 additions & 3 deletions src/EFCore.Cosmos/Query/Internal/SelectExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ public virtual void ApplyLimit(SqlExpression sqlExpression)
{
if (Limit != null)
{
throw new InvalidOperationException("See issue#16156");
throw new InvalidOperationException(
CoreStrings.TranslationFailedWithDetails(
sqlExpression.Print(),
CosmosStrings.NoSubqueryPushdown));
}

Limit = sqlExpression;
Expand All @@ -348,7 +351,10 @@ public virtual void ApplyOffset(SqlExpression sqlExpression)
if (Limit != null
|| Offset != null)
{
throw new InvalidOperationException("See issue#16156");
throw new InvalidOperationException(
CoreStrings.TranslationFailedWithDetails(
sqlExpression.Print(),
CosmosStrings.NoSubqueryPushdown));
}

Offset = sqlExpression;
Expand All @@ -366,7 +372,10 @@ public virtual void ApplyOrdering(OrderingExpression orderingExpression)
|| Limit != null
|| Offset != null)
{
throw new InvalidOperationException("See issue#16156");
throw new InvalidOperationException(
CoreStrings.TranslationFailedWithDetails(
orderingExpression.Print(),
CosmosStrings.NoSubqueryPushdown));
}

_orderings.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1056,22 +1056,22 @@ ORDER BY c["CustomerID"]

public override async Task Distinct_OrderBy(bool async)
// Subquery pushdown. Issue #16156.
=> Assert.Equal(
"See issue#16156",
(await Assert.ThrowsAsync<InvalidOperationException>(async () => await base.Distinct_OrderBy(async))).Message);
=> await AssertTranslationFailedWithDetails(
() => base.Distinct_OrderBy(async),
CosmosStrings.NoSubqueryPushdown);

public override async Task Distinct_OrderBy2(bool async)
// Subquery pushdown. Issue #16156.
=> Assert.Equal(
"See issue#16156",
(await Assert.ThrowsAsync<InvalidOperationException>(async () => await base.Distinct_OrderBy2(async))).Message);
=> await AssertTranslationFailedWithDetails(
() => base.Distinct_OrderBy2(async),
CosmosStrings.NoSubqueryPushdown);

public override async Task Distinct_OrderBy3(bool async)
{
// Subquery pushdown. Issue #16156.
Assert.Equal(
"See issue#16156",
(await Assert.ThrowsAsync<InvalidOperationException>(async () => await base.Distinct_OrderBy3(async))).Message);
await AssertTranslationFailedWithDetails(
() => base.Distinct_OrderBy(async),
CosmosStrings.NoSubqueryPushdown);

AssertSql();
}
Expand Down
Loading