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

Query: Select Where Navigation returns wrong results on relational providers #5179

Closed
mikary opened this issue Apr 26, 2016 · 2 comments
Closed
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@mikary
Copy link
Contributor

mikary commented Apr 26, 2016

The existing test in QueryNavigationsTestBase returns the correct number of results but incorrect values on relational providers.

        [ConditionalFact]
        public virtual void Select_Where_Navigation()
        {
            using (var context = CreateContext())
            {
                var orders
                    = (from o in context.Set<Order>()
                       where o.Customer.City == "Seattle"
                       select o).ToList();

                Assert.Equal(14, orders.Count);
            }
        }

The list of orders contains 14 references to the same order (10904 on SqlServer, 10269 on Sqlite) instead of the expected results for the query. Results appear to be correct on the InMemory provider.

@mikary
Copy link
Contributor Author

mikary commented Apr 26, 2016

Generated SQL for SqlServer:

SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate], [o.Customer].[CustomerID], [o.Customer].[Address], [o.Customer].[City], [o.Customer].[CompanyName], [o.Customer].[ContactName], [o.Customer].[ContactTitle], [o.Customer].[Country], [o.Customer].[Fax], [o.Customer].[Phone], [o.Customer].[PostalCode], [o.Customer].[Region]
FROM [Orders] AS [o]
LEFT JOIN [Customers] AS [o.Customer] ON [o].[CustomerID] = [o.Customer].[CustomerID]
ORDER BY [o].[CustomerID]

@rowanmiller rowanmiller added this to the 1.0.0-rc2 milestone Apr 26, 2016
@rowanmiller
Copy link
Contributor

@maumar this should be your top priority

maumar added a commit that referenced this issue Apr 28, 2016
…n relational providers

Problem was that when creating groups in GroupJoin we would only look at the inner key selector to differentiate between groups. However in some cases (specifically 1-Many navigations coming from the many side - e.g. order.Customer) outer element constantly changes, while inner element stays the same. If later in the pipeline outer elements are being used, e.g. in projection, we get incorrect results.

Fix is to also look at changes between outer elements and create a new group every time either outer element or a inner key changes.

Also as part of this change we improve result verification for the navigation tests (previously we would only verify that the result count is as expected).
anpete added a commit that referenced this issue Apr 29, 2016
…lational providers

Fixed streaming relational GroupJoin operator to correctly re-group on outer element change.
anpete added a commit that referenced this issue Apr 29, 2016
…lational providers

Fixed streaming relational GroupJoin operator to correctly re-group on outer element change.

Also fixed some places where we were failing to flow cancellation tokens.
@rowanmiller rowanmiller assigned anpete and unassigned maumar Apr 29, 2016
@anpete anpete closed this as completed in e169d17 Apr 29, 2016
anpete added a commit that referenced this issue May 2, 2016
…lational providers

Fixed streaming relational GroupJoin operator to correctly re-group on outer element change.

Also fixed some places where we were failing to flow cancellation tokens.
@ajcvickers ajcvickers modified the milestones: 1.0.0-rc2, 1.0.0 Oct 15, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

5 participants