Skip to content

Commit

Permalink
Remove SplitQueryOffsetWithoutOrderBy error checking that can't happe…
Browse files Browse the repository at this point in the history
…n anymore
  • Loading branch information
ascott18 committed Jul 30, 2024
1 parent a18106f commit 34a956b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,10 @@ static Expression RemoveConvert(Expression expression)
{
var outerSelectExpression = (SelectExpression)cloningExpressionVisitor!.Visit(baseSelectExpression!);

// Inject deterministic orderings (the identifier columns) to both the main query and the split query.
// Note that just below we pushdown the split query if it has limit/offset/distinct/groupby; this ensures
// that the orderings are also propagated to that split subquery if it has limit/offset, which ensures that
// that subquery returns the same rows as the main query (#26808)
// Inject deterministic orderings (the identifier columns) to both the main query and the split query.
// Note that just below we pushdown the split query if it has limit/offset/distinct/groupby; this ensures
// that the orderings are also propagated to that split subquery if it has limit/offset, which ensures that
// that subquery returns the same rows as the main query (#26808)
var actualParentIdentifier = _identifier.Take(outerSelectExpression._identifier.Count).ToList();
for (var j = 0; j < actualParentIdentifier.Count; j++)
{
Expand Down
6 changes: 0 additions & 6 deletions src/EFCore.SqlServer/Properties/SqlServerStrings.Designer.cs

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

3 changes: 0 additions & 3 deletions src/EFCore.SqlServer/Properties/SqlServerStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@
<data name="SequenceBadType" xml:space="preserve">
<value>SQL Server sequences cannot be used to generate values for the property '{property}' on entity type '{entityType}' because the property type is '{propertyType}'. Sequences can only be used with integer properties.</value>
</data>
<data name="SplitQueryOffsetWithoutOrderBy" xml:space="preserve">
<value>The query uses 'Skip' without specifying ordering and uses split query mode. This generates incorrect results. Either provide ordering or run query in single query mode using `AsSingleQuery()`. See https://go.microsoft.com/fwlink/?linkid=2196526 for more information.</value>
</data>
<data name="TemporalAllEntitiesMappedToSameTableMustBeTemporal" xml:space="preserve">
<value>Entity type '{entityType}' should be marked as temporal because it shares table mapping with another entity that has been marked as temporal. Alternatively, other entity types that share the same table must be non-temporal.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Internal;
public class SqlServerQueryTranslationPostprocessor : RelationalQueryTranslationPostprocessor
{
private readonly SqlServerJsonPostprocessor _jsonPostprocessor;
private readonly SkipWithoutOrderByInSplitQueryVerifier _skipWithoutOrderByInSplitQueryVerifier = new();
private readonly SqlServerSqlTreePruner _pruner = new();

/// <summary>
Expand Down Expand Up @@ -47,7 +46,6 @@ public override Expression Process(Expression query)
var query1 = base.Process(query);

var query2 = _jsonPostprocessor.Process(query1);
_skipWithoutOrderByInSplitQueryVerifier.Visit(query2);

return query2;
}
Expand All @@ -69,37 +67,4 @@ protected override Expression ProcessTypeMappings(Expression expression)
/// </summary>
protected override Expression Prune(Expression query)
=> _pruner.Prune(query);

private sealed class SkipWithoutOrderByInSplitQueryVerifier : ExpressionVisitor
{
[return: NotNullIfNotNull(nameof(expression))]
public override Expression? Visit(Expression? expression)
{
switch (expression)
{
case ShapedQueryExpression shapedQueryExpression:
Visit(shapedQueryExpression.ShaperExpression);
return shapedQueryExpression;

case RelationalSplitCollectionShaperExpression relationalSplitCollectionShaperExpression:
foreach (var table in relationalSplitCollectionShaperExpression.SelectExpression.Tables)
{
Visit(table);
}

Visit(relationalSplitCollectionShaperExpression.InnerShaper);

return relationalSplitCollectionShaperExpression;

case SelectExpression { Offset: not null, Orderings.Count: 0 }:
throw new InvalidOperationException(SqlServerStrings.SplitQueryOffsetWithoutOrderBy);

case NonQueryExpression nonQueryExpression:
return nonQueryExpression;

default:
return base.Visit(expression);
}
}
}
}

0 comments on commit 34a956b

Please sign in to comment.