Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public async ValueTask<bool> MoveNextAsync(ITrace trace, CancellationToken cance
}

TryCatch<bool> hasNext = await this.inner.TryAsync(pipelineStage => pipelineStage.MoveNextAsync(trace, cancellationToken));
return hasNext.Succeeded && hasNext.Result;
return hasNext.Failed || hasNext.Result;
}

public ValueTask DisposeAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,58 @@ await this.CreateIngestQueryDeleteAsync(
},
"/id",
indexV2Policy);
}

[TestMethod]
public async Task TestBadOrderByQueriesAsync()
{
const string NoCompositeIndex = "The order by query does not have a corresponding composite index that it can be served from.";
const string OrderByOverCorrelatedPath = "Order-by over correlated collections is not supported.";

static async Task ImplementationAsync(
Container container,
IReadOnlyList<CosmosObject> documents)
{
IReadOnlyList<(string query, string error)> queries = new List<(string query, string error)>
{
("SELECT * FROM c ORDER BY c.id, c.name", NoCompositeIndex),
("SELECT * FROM c ORDER BY c.id DESC, c._ts DESC", NoCompositeIndex),
(
@"SELECT DISTINCT VALUE v2
FROM root
JOIN (
SELECT DISTINCT VALUE v0
FROM root
JOIN v0 IN root.Parents) AS v2
WHERE (LENGTH(v2.FamilyName) > 10)
ORDER BY v2 ASC",
OrderByOverCorrelatedPath
),
};

foreach (bool enableOptmisticDirectExecution in new []{ false, true })
{
QueryRequestOptions options = new QueryRequestOptions()
{
EnableOptimisticDirectExecution = enableOptmisticDirectExecution,
};

foreach ((string query, string error) in queries)
{
using FeedIterator feedIterator = container.GetItemQueryStreamIterator(query, continuationToken: null, options);
ResponseMessage response = await feedIterator.ReadNextAsync();
Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, response.StatusCode);
Assert.IsNotNull(response.CosmosException);
Assert.IsTrue(response.CosmosException.Message.Contains(error));
}
}
}

await this.CreateIngestQueryDeleteAsync(
ConnectionModes.Direct | ConnectionModes.Gateway,
CollectionTypes.SinglePartition | CollectionTypes.MultiPartition,
new List<string>(),
ImplementationAsync);
}

private sealed class MixedTypedDocument
Expand Down