-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Full management of SQL operator precedence/associativity
Removing unnecessary parentheses Closes #26767
- Loading branch information
Showing
71 changed files
with
4,674 additions
and
4,070 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
test/EFCore.Relational.Specification.Tests/Query/NorthwindOperatorsQueryTestBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.TestModels.Northwind; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Query; | ||
|
||
public abstract class NorthwindOperatorsQueryTestBase<TFixture> : QueryTestBase<TFixture> | ||
where TFixture : NorthwindQueryFixtureBase<NoopModelCustomizer>, new() | ||
{ | ||
protected NorthwindOperatorsQueryTestBase(TFixture fixture) | ||
: base(fixture) | ||
{ | ||
} | ||
|
||
protected static ExpressionType[] BinaryArithmeticOperators { get; } = | ||
{ | ||
ExpressionType.Add, | ||
ExpressionType.Subtract, | ||
ExpressionType.Multiply, | ||
ExpressionType.Divide, | ||
// TODO Complete... | ||
}; | ||
|
||
[ConditionalTheory] | ||
[MemberData(nameof(Get_binary_arithmetic_data))] | ||
public virtual async Task Binary_arithmetic_operators(ExpressionType outer, ExpressionType inner) | ||
{ | ||
var parameter = Expression.Parameter(typeof(Order), "o"); | ||
var predicate = | ||
Expression.Lambda<Func<Order, int>>( | ||
Expression.MakeBinary( | ||
outer, | ||
Expression.MakeBinary( | ||
inner, | ||
Expression.Property(parameter, nameof(Order.OrderID)), | ||
Expression.Constant(8)), | ||
Expression.Constant(9)), | ||
parameter); | ||
|
||
await AssertQueryScalar( | ||
async: true, | ||
ss => ss.Set<Order>().Where(o => o.OrderID == 10248).Select(predicate)); | ||
} | ||
|
||
public static IEnumerable<object[]> Get_binary_arithmetic_data() | ||
=> from op1 in BinaryArithmeticOperators from op2 in BinaryArithmeticOperators select new object[] { op1, op2 }; | ||
|
||
[ConditionalTheory] | ||
[MemberData(nameof(IsAsyncData))] | ||
public virtual Task Double_negate_on_column(bool async) | ||
=> AssertQuery( | ||
async, | ||
ss => ss.Set<Order>().Where(o => -(-o.OrderID) == o.OrderID), | ||
entryCount: 830); | ||
|
||
// TODO: Test associativity (no parentheses on consecutive e.g. add operations) | ||
// TODO: Test non-associativity of arithmetic operators on floating points aren't associative (because of rounding errors) | ||
|
||
// TODO: Move operator/precedence related here, e.g. NullSemanticsQueryTestBase.Bool_not_equal_nullable_int_HasValue, | ||
// GearsOfWarTestBase.Negate_on_binary_expression... | ||
} |
Oops, something went wrong.