-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Conversation
@@ -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(); |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctor dependency?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 💣
There was a problem hiding this comment.
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! 🙌
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we cache this?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null check?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null annotation.
347686c
to
c52548b
Compare
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
c52548b
to
e6f0e19
Compare
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