Skip to content
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

Add owned entity types support to more places in query #8249

Merged
merged 1 commit into from
Apr 22, 2017

Conversation

AndriySvyryd
Copy link
Member

Record the EntityType when visiting existing JoinClause
Update QuerySourceMapping when cloning
Add provider-specific model building extensions
Add more query tests for owned entity types

@@ -4249,9 +4439,11 @@ where l2.OneToOne_Required_FK.OneToMany_Optional.Select(i => i.OneToOne_Optional
{
using (var context = CreateContext())
{
var expected = l2oQuery(ExpectedSet<TItem1>()).ToArray();
var actual = efQuery(Set<TItem1>(context)).ToArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch the order so that actual executes first (in case expected has a null ref or something)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't you want to see the exception in expected first, so that you don't waste time debugging actual?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if expected runs first and throws, then the product code never runs - in my experience, exceptions coming from expected (in this test suite at least) are mostly due to null refs during nav access, something that is perfectly fine for the product query.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

private bool SupportsOffset => TestEnvironment.GetFlag(nameof(SqlServerCondition.SupportsOffset)) ?? true;

[ConditionalFact]
public override void Where_nav_prop_reference_optional1()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

}

// One-to-many not supported yet
public override void Multiple_SelectMany_with_string_based_Include()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add skip annotation here also? or would that be too much spam in the build.cmd?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Skip is only for tests that are expected to pass

int index,
IPropertyBase property = null)
{
object untypedValue = null;

var untypedValue = valueBuffer[index];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can throw null ref

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and in that case the exception message would be wrong:
An exception occurred while reading a database value for property 'Order.ReplacedOrderId'. The expected type was 'int?' but the actual value was null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No existing tests fails, right? If not, then I think this is OK. We are effectively saying that seeing ValueBuffer.Empty is an error here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we throw in either case, just the exception is different

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and we are discussing whether that is correct 😄 This change asserts that a null coming from the database (incorrectly) never results in ValueBuffer.Empty appearing in the executing query.

Copy link
Contributor

@maumar maumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test changes look good

@@ -81,18 +69,18 @@ public QueryOptimizer([NotNull] IModel model)
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public virtual void Optimize(
IReadOnlyCollection<IQueryAnnotation> queryAnnotations,
QueryCompilationContext queryCompilationContext,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctor dependency?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryCompilationContext is not in DI

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I had assumed that QueryOptimizer was not in DI. Makes me wonder whether having QueryOptimizer in DI is correct as it has state - We have to be careful here 💣

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I see that your change improves this situation! 🙌

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #8256

}
[param: CanBeNull] set { SetTableName(value); }
}

private string GetDefaultTableName()
=> EntityType.HasDelegatedIdentity()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we cache this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, more caching never hurts

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a relational concept, proper caching would require non-trivial infrastructure changes, I think it's better to do it as part of #8258


/// <summary>
/// This API supports the Entity Framework Core infrastructure and is not intended to be used
/// directly from your code. This API may change or be removed in future releases.
/// </summary>
public EntityEqualityRewritingExpressionVisitor([NotNull] IModel model)
public EntityEqualityRewritingExpressionVisitor([NotNull] QueryCompilationContext queryCompilationContext)
{
Copy link
Contributor

@smitpatel smitpatel Apr 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need checks on .Internal API

/// Updates the query source mappings to the new query sources
/// </summary>
/// <param name="querySourceMapping"> The new query source mapping </param>
public virtual void UpdateMapping(QuerySourceMapping querySourceMapping)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null annotation.

@AndriySvyryd AndriySvyryd force-pushed the DelegatedIdentityQueryTests branch from 347686c to c52548b Compare April 21, 2017 22:39
Record the EntityType when visiting existing JoinClause
Update QuerySourceMapping when cloning
Add provider-specific model building extensions
Add more query tests for owned entity types
@AndriySvyryd AndriySvyryd force-pushed the DelegatedIdentityQueryTests branch from c52548b to e6f0e19 Compare April 22, 2017 00:31
@AndriySvyryd AndriySvyryd merged commit e6f0e19 into dev Apr 22, 2017
@AndriySvyryd AndriySvyryd deleted the DelegatedIdentityQueryTests branch April 22, 2017 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants