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 complex type support to the update pipeline #31409

Merged
merged 1 commit into from
Aug 7, 2023
Merged

Conversation

AndriySvyryd
Copy link
Member

The state management part is prototype quality, expected to be replaced by @ajcvickers.

Part of #13947

@AndriySvyryd AndriySvyryd requested a review from a team August 4, 2023 20:05
@AndriySvyryd AndriySvyryd force-pushed the Issue13947_part6 branch 3 times, most recently from a72dea7 to 94285b4 Compare August 6, 2023 10:15
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

LGTM, mostly nits (but see the question on the entry type factoring)

src/EFCore/ChangeTracking/Internal/ComplexEntries.cs Outdated Show resolved Hide resolved
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public bool IsModified(IProperty property)
Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked through, but there seems to be at least some duplicated code between InternalEntityEntry and InternalComplexEntry. We could have InternalEntry as a base class instead of an interface and move the common code there.

If most of the logic is the same, we could even just have a single InternalEntry that contains an ITypeBase, and just checks entity vs. complex in the specific paths where the logic diverges. For example, we may not support navigations on complex types today, but I think we want to do that in the future; at that point I'm not sure what the differences between the entry types are.

(am going through all these considerations in the query pipeline at the moment...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently they are very similar indeed, but as I mentioned in the other comment I don't think this is going to be the case long term, so it's not really worth the effort right now.

src/EFCore/ChangeTracking/Internal/InternalEntityEntry.cs Outdated Show resolved Hide resolved
Expression.Property(parameter!, "Entity"),
Expression.Property(parameter!, parameter!.Type == typeof(InternalEntityEntry)
? nameof(InternalEntityEntry.Entity)
: nameof(IInternalEntry.Object)),
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason to not always use IInternalEntry.Object? If there is one, does it not also apply for using InternalComplexEntry.ComplexObject?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly because I don't think IInternalEntry.Object is a good solution in the long term as it won't work for value types.

column.IsNullable = property.IsColumnNullable(mappedQuery);
column = new SqlQueryColumn(columnName, property.GetColumnType(mappedQuery), sqlQuery)
{
IsNullable = property.IsColumnNullable(mappedQuery)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe accept nullable in the ctor for SqlQueryColumn (it isn't instantiated anywhere else)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's instantiated in the compiled relational model.

@@ -111,7 +111,8 @@ public virtual IReadOnlyList<IColumnModification> ColumnModifications
[EntityFrameworkInternal]
public virtual void AssertColumnsNotInitialized()
{
if (_columnModifications != null)
if (_columnModifications != null
&& !Debugger.IsAttached)
Copy link
Member

Choose a reason for hiding this comment

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

Is this because looking at _columnModifications in the debugger populates it and causes an exception later? If so, yeah - I also found it annoying, but maybe we should simply have a more explicit step for calculating the modifications rather than doing it automatically upon read?

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, but an explicit step decreases the usability in code. I prefer to sacrifice the debugging experience.

src/EFCore.Relational/Update/ModificationCommand.cs Outdated Show resolved Hide resolved
//Assert.Equal(scooter.SeatingCapacity, scooterEntry.ComplexProperty(v => v.Engine).TargetEntry.Property<int>("SeatingCapacity").CurrentValue);
}

//using (var context = CreateContext())
Copy link
Member

Choose a reason for hiding this comment

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

👀

(also below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends on query implementation

@AndriySvyryd AndriySvyryd changed the base branch from Issue13947_part5 to main August 7, 2023 18:05
@AndriySvyryd AndriySvyryd merged commit 11bced2 into main Aug 7, 2023
7 checks passed
@AndriySvyryd AndriySvyryd deleted the Issue13947_part6 branch August 7, 2023 19:35
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.

3 participants