Skip to content

Commit

Permalink
Disabling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smitpatel committed May 2, 2019
1 parent 4fdbdd5 commit 35169f8
Show file tree
Hide file tree
Showing 91 changed files with 641 additions and 498 deletions.
4 changes: 2 additions & 2 deletions src/EFCore.InMemory/Query/PipeLine/EntityValuesExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline
{
public class EntityValuesExpression : Expression
public class EntityProjectionExpression : Expression
{
public EntityValuesExpression(IEntityType entityType, int startIndex)
public EntityProjectionExpression(IEntityType entityType, int startIndex)
{
EntityType = entityType;
StartIndex = startIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Storage;

Expand Down Expand Up @@ -52,6 +54,25 @@ public override Expression Visit(Expression expression)
|| expression is MemberInitExpression
|| expression is EntityShaperExpression))
{
// This converts object[] from GetDatabaseValues to appropriate projection.
if (expression is NewArrayExpression newArrayExpression
&& newArrayExpression.NodeType == ExpressionType.NewArrayInit
&& newArrayExpression.Expressions.Count > 0
&& newArrayExpression.Expressions[0] is UnaryExpression unaryExpression
&& unaryExpression.NodeType == ExpressionType.Convert
&& unaryExpression.Type == typeof(object)
&& unaryExpression.Operand is MethodCallExpression methodCall
&& methodCall.Method.IsEFPropertyMethod()
&& methodCall.Arguments[0] is EntityShaperExpression entityShaperExpression
&& entityShaperExpression.EntityType.GetProperties().Count() == newArrayExpression.Expressions.Count)
{
_projectionMapping[_projectionMembers.Peek()]
= _queryExpression.GetProjectionExpression(
entityShaperExpression.ValueBufferExpression.ProjectionMember);

return new EntityValuesExpression(entityShaperExpression.EntityType, entityShaperExpression.ValueBufferExpression);
}

var translation = _expressionTranslatingExpressionVisitor.Translate(_queryExpression, expression);

_projectionMapping[_projectionMembers.Peek()] = translation;
Expand Down
14 changes: 7 additions & 7 deletions src/EFCore.InMemory/Query/PipeLine/InMemoryQueryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public InMemoryQueryExpression(IEntityType entityType)
{
ServerQueryExpression = new InMemoryTableExpression(entityType);

var entityValues = new EntityValuesExpression(entityType, 0);
var entityValues = new EntityProjectionExpression(entityType, 0);
_projectionMapping[new ProjectionMember()] = entityValues;
foreach (var property in entityType.GetProperties())
{
Expand All @@ -97,7 +97,7 @@ public Expression BindProperty(Expression projectionExpression, IProperty proper
{
var member = (projectionExpression as ProjectionBindingExpression).ProjectionMember;

var entityValuesExpression = (EntityValuesExpression)_projectionMapping[member];
var entityValuesExpression = (EntityProjectionExpression)_projectionMapping[member];
var offset = entityValuesExpression.StartIndex;

return _valueBufferSlots[offset + property.GetIndex()];
Expand All @@ -113,14 +113,14 @@ public void ApplyProjection(IDictionary<ProjectionMember, Expression> projection
var member = kvp.Key;
var expression = kvp.Value;
var currentIndex = _valueBufferSlots.Count;
if (expression is EntityValuesExpression entityValuesExpression)
if (expression is EntityProjectionExpression entityValuesExpression)
{
foreach (var property in entityValuesExpression.EntityType.GetProperties())
{
_valueBufferSlots.Add(CreateReadValueExpression(property.ClrType, currentIndex + property.GetIndex(), property));
}

_projectionMapping[member] = new EntityValuesExpression(entityValuesExpression.EntityType, currentIndex);
_projectionMapping[member] = new EntityProjectionExpression(entityValuesExpression.EntityType, currentIndex);
}
else
{
Expand All @@ -133,7 +133,7 @@ public void ApplyProjection(IDictionary<ProjectionMember, Expression> projection
public Expression GetProjectionExpression(ProjectionMember member)
{
var projection = _projectionMapping[member];
if (projection is EntityValuesExpression entityValues)
if (projection is EntityProjectionExpression entityValues)
{
return entityValues;
}
Expand Down Expand Up @@ -276,9 +276,9 @@ public void AddInnerJoin(
foreach (var projection in queryExpression._projectionMapping)
{
var updatedProjection = projection.Value;
if (updatedProjection is EntityValuesExpression entityValues)
if (updatedProjection is EntityProjectionExpression entityValues)
{
updatedProjection = new EntityValuesExpression(entityValues.EntityType, entityValues.StartIndex + offset);
updatedProjection = new EntityProjectionExpression(entityValues.EntityType, entityValues.StartIndex + offset);
}
projectionMapping[projection.Key.ShiftMember(innerMemberInfo)] = updatedProjection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ protected override Expression VisitBinary(BinaryExpression binaryExpression)

var innerExpression = Visit(newExpression.Arguments[0]);

var entityStartIndex = ((EntityValuesExpression)innerExpression).StartIndex;
var entityStartIndex = ((EntityProjectionExpression)innerExpression).StartIndex;
_materializationContextBindings[parameterExpression] = entityStartIndex;

var updatedExpression = Expression.New(newExpression.Constructor,
Expand All @@ -220,7 +220,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp
{
var originalIndex = (int)((ConstantExpression)methodCallExpression.Arguments[1]).Value;
var indexOffset = methodCallExpression.Arguments[0] is ProjectionBindingExpression projectionBindingExpression
? ((EntityValuesExpression)_queryExpression.GetProjectionExpression(projectionBindingExpression.ProjectionMember)).StartIndex
? ((EntityProjectionExpression)_queryExpression.GetProjectionExpression(projectionBindingExpression.ProjectionMember)).StartIndex
: _materializationContextBindings[(ParameterExpression)((MethodCallExpression)methodCallExpression.Arguments[0]).Object];

return Expression.Call(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public SqlExpression Translate(SqlExpression instance, MethodInfo method, IList<
if (Equals(method, _methodInfo))
{
var argument = arguments[0];
Debug.Assert(argument.TypeMapping != null, "Must have typeMapping.");

return _sqlExpressionFactory.OrElse(
_sqlExpressionFactory.IsNull(argument),
Expand Down
12 changes: 6 additions & 6 deletions src/EFCore.Relational/Query/PipeLine/QuerySqlGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,32 +228,32 @@ protected override Expression VisitSqlBinary(SqlBinaryExpression sqlBinaryExpres
}
else
{
var needsParenthesis = RequiresBrackets(sqlBinaryExpression.Left);
var requiresBrackets = RequiresBrackets(sqlBinaryExpression.Left);

if (needsParenthesis)
if (requiresBrackets)
{
_relationalCommandBuilder.Append("(");
}

Visit(sqlBinaryExpression.Left);

if (needsParenthesis)
if (requiresBrackets)
{
_relationalCommandBuilder.Append(")");
}

_relationalCommandBuilder.Append(GenerateOperator(sqlBinaryExpression));

needsParenthesis = RequiresBrackets(sqlBinaryExpression.Right);
requiresBrackets = RequiresBrackets(sqlBinaryExpression.Right);

if (needsParenthesis)
if (requiresBrackets)
{
_relationalCommandBuilder.Append("(");
}

Visit(sqlBinaryExpression.Right);

if (needsParenthesis)
if (requiresBrackets)
{
_relationalCommandBuilder.Append(")");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore.Extensions.Internal;
using Microsoft.EntityFrameworkCore.Query.Pipeline;
using Microsoft.EntityFrameworkCore.Relational.Query.Pipeline.SqlExpressions;
using Microsoft.EntityFrameworkCore.Storage;
Expand Down Expand Up @@ -54,13 +56,33 @@ public override Expression Visit(Expression expression)
|| expression is MemberInitExpression
|| expression is EntityShaperExpression))
{
// This skips the group parameter from GroupJoin
if (expression is ParameterExpression parameter
&& parameter.Type.IsGenericType
&& parameter.Type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
return parameter;
}

// This converts object[] from GetDatabaseValues to appropriate projection.
if (expression is NewArrayExpression newArrayExpression
&& newArrayExpression.NodeType == ExpressionType.NewArrayInit
&& newArrayExpression.Expressions.Count > 0
&& newArrayExpression.Expressions[0] is UnaryExpression unaryExpression
&& unaryExpression.NodeType == ExpressionType.Convert
&& unaryExpression.Type == typeof(object)
&& unaryExpression.Operand is MethodCallExpression methodCall
&& methodCall.Method.IsEFPropertyMethod()
&& methodCall.Arguments[0] is EntityShaperExpression entityShaperExpression
&& entityShaperExpression.EntityType.GetProperties().Count() == newArrayExpression.Expressions.Count)
{
_projectionMapping[_projectionMembers.Peek()]
= _selectExpression.GetProjectionExpression(
entityShaperExpression.ValueBufferExpression.ProjectionMember);

return new EntityValuesExpression(entityShaperExpression.EntityType, entityShaperExpression.ValueBufferExpression);
}

var translation = _sqlTranslator.Translate(_selectExpression, expression);

_projectionMapping[_projectionMembers.Peek()] = translation ?? throw new InvalidOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ protected override ShapedQueryExpression TranslateLastOrDefault(
selectExpression.PushdownIntoSubQuery();
}

selectExpression.Reverse();
selectExpression.ReverseOrderings();
selectExpression.ApplyLimit(TranslateExpression(selectExpression, Expression.Constant(1)));

if (source.ShaperExpression.ReturnType != returnType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ protected override Expression VisitUnary(UnaryExpression unaryExpression)
if (operand.Type.IsInterface
&& unaryExpression.Type.GetInterfaces().Any(e => e == operand.Type)
|| unaryExpression.Type.UnwrapNullableType() == operand.Type
|| unaryExpression.Type.UnwrapNullableType() == typeof(Enum))
|| unaryExpression.Type.UnwrapNullableType() == typeof(Enum)
|| unaryExpression.Type == typeof(object))
{
return sqlOperand;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void ApplyOffset(SqlExpression sqlExpression)
Offset = sqlExpression;
}

public void Reverse()
public void ReverseOrderings()
{
var existingOrdering = _orderings.ToArray();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override int GetHashCode()
{
var hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ Table.GetHashCode();
hashCode = (hashCode * 397) ^ Schema.GetHashCode();
hashCode = (hashCode * 397) ^ (Schema?.GetHashCode() ?? 0);

return hashCode;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EFCore/Internal/EntityFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private IQueryable<object[]> GetDatabaseValuesQuery(InternalEntityEntry entry)
keyValues[i] = keyValue;
}

return _queryRoot.AsNoTracking().IgnoreQueryFilters()
return _queryRoot.AsNoTracking()//.IgnoreQueryFilters()
.Where(BuildObjectLambda(properties, new ValueBuffer(keyValues)))
.Select(BuildProjection(entityType));
}
Expand Down
29 changes: 29 additions & 0 deletions src/EFCore/Query/PipeLine/EntityShaperExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,35 @@ public EntityShaperExpression Update(ProjectionBindingExpression valueBufferExpr
public override ExpressionType NodeType => ExpressionType.Extension;
}

public class EntityValuesExpression : Expression
{
public EntityValuesExpression(IEntityType entityType, ProjectionBindingExpression valueBufferExpression)
{
EntityType = entityType;
ValueBufferExpression = valueBufferExpression;
}

public IEntityType EntityType { get; }
public ProjectionBindingExpression ValueBufferExpression { get; }

protected override Expression VisitChildren(ExpressionVisitor visitor)
{
var valueBufferExpression = (ProjectionBindingExpression)visitor.Visit(ValueBufferExpression);

return Update(valueBufferExpression);
}

public EntityValuesExpression Update(ProjectionBindingExpression valueBufferExpression)
{
return valueBufferExpression != ValueBufferExpression
? new EntityValuesExpression(EntityType, valueBufferExpression)
: this;
}

public override Type Type => typeof(object[]);
public override ExpressionType NodeType => ExpressionType.Extension;
}

public class CollectionShaperExpression : Expression
{
public CollectionShaperExpression(
Expand Down
12 changes: 12 additions & 0 deletions src/EFCore/Query/PipeLine/ShapedQueryExpressionVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ protected override Expression VisitExtension(Expression extensionExpression)
return result;
}

if (extensionExpression is EntityValuesExpression entityValuesExpression)
{
return Expression.NewArrayInit(
typeof(object),
entityValuesExpression.EntityType.GetProperties()
.Select(p => _entityMaterializerSource.CreateReadValueExpression(
entityValuesExpression.ValueBufferExpression,
typeof(object),
p.GetIndex(),
p)));
}

if (extensionExpression is CollectionShaperExpression collectionShaper)
{
var keyType = collectionShaper.OuterKey.Type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// ReSharper disable StringStartsWithIsCultureSpecific
namespace Microsoft.EntityFrameworkCore
{
public class DatabaseErrorLogStateTest
internal class DatabaseErrorLogStateTest
{
[Fact]
public Task SaveChanges_logs_DatabaseErrorLogState_nonasync()
Expand Down
19 changes: 18 additions & 1 deletion test/EFCore.InMemory.FunctionalTests/InMemoryComplianceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,24 @@ public class InMemoryComplianceTest : ComplianceTestBase
typeof(ComplexNavigationsWeakQueryTestBase<>), // issue #15285
typeof(FiltersInheritanceTestBase<>), // issue #15264
typeof(FiltersTestBase<>), // issue #15264
typeof(OwnedQueryTestBase<>) // issue #15285
typeof(OwnedQueryTestBase<>), // issue #15285
// Query pipeline
typeof(ConcurrencyDetectorTestBase<>),
typeof(AsNoTrackingTestBase<>),
typeof(AsTrackingTestBase<>),
typeof(CompiledQueryTestBase<>),
typeof(ComplexNavigationsQueryTestBase<>),
typeof(GearsOfWarQueryTestBase<>),
typeof(IncludeAsyncTestBase<>),
typeof(IncludeOneToOneTestBase<>),
typeof(IncludeTestBase<>),
typeof(InheritanceRelationshipsQueryTestBase<>),
typeof(InheritanceTestBase<>),
typeof(NullKeysTestBase<>),
typeof(QueryNavigationsTestBase<>),
typeof(QueryTaggingTestBase<>),
typeof(SpatialQueryTestBase<>),
typeof(UpdatesTestBase<>),
};

protected override Assembly TargetAssembly { get; } = typeof(InMemoryComplianceTest).Assembly;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.EntityFrameworkCore.Query
{
public class AsNoTrackingInMemoryTest : AsNoTrackingTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
internal class AsNoTrackingInMemoryTest : AsNoTrackingTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
{
public AsNoTrackingInMemoryTest(NorthwindQueryInMemoryFixture<NoopModelCustomizer> fixture)
: base(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Microsoft.EntityFrameworkCore.Query
{
public class AsTrackingInMemoryTest : AsTrackingTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
internal class AsTrackingInMemoryTest : AsTrackingTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
{
public AsTrackingInMemoryTest(NorthwindQueryInMemoryFixture<NoopModelCustomizer> fixture)
: base(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.EntityFrameworkCore.Query
{
public class CompiledQueryInMemoryTest : CompiledQueryTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
internal class CompiledQueryInMemoryTest : CompiledQueryTestBase<NorthwindQueryInMemoryFixture<NoopModelCustomizer>>
{
public CompiledQueryInMemoryTest(NorthwindQueryInMemoryFixture<NoopModelCustomizer> fixture)
: base(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.EntityFrameworkCore.Query
{
public class ComplexNavigationsQueryInMemoryTest : ComplexNavigationsQueryTestBase<ComplexNavigationsQueryInMemoryFixture>
internal class ComplexNavigationsQueryInMemoryTest : ComplexNavigationsQueryTestBase<ComplexNavigationsQueryInMemoryFixture>
{
public ComplexNavigationsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Microsoft.EntityFrameworkCore.Query
{
public class GearsOfWarQueryInMemoryTest : GearsOfWarQueryTestBase<GearsOfWarQueryInMemoryFixture>
internal class GearsOfWarQueryInMemoryTest : GearsOfWarQueryTestBase<GearsOfWarQueryInMemoryFixture>
{
public GearsOfWarQueryInMemoryTest(GearsOfWarQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper)
: base(fixture)
Expand Down
Loading

0 comments on commit 35169f8

Please sign in to comment.