Test bug: Include_collection_with_cross_apply_with_filter relies on nondeterministic ORDER BY with Take
Maintainer thường phản hồi trong vòng 2 ngày
@Mohamedadel-prog đang làm issue này rồi.
Từ ngày 29/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 66/100
Hướng nghiên cứu
Đọc test/EFCore.Specification.Tests/Query/NorthwindIncludeQueryTestBase.cs, đặc biệt là Include_collection_with_cross_apply_with_filter và các biến thể outer_apply liền kề. Kiểm tra cách các bài kiểm thử này xác nhận các collection được include và xác định liệu có thể thêm thứ tự duy nhất hoặc làm cho assertion không phụ thuộc vào thứ tự hay không. Hoàn thành khi các bài kiểm thử không còn phụ thuộc vào kết quả đồng hạng của ORDER BY; chạy các bài kiểm thử truy vấn liên quan để xác minh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
NorthwindIncludeQueryTestBase.Include_collection_with_cross_apply_with_filter (and the outer_apply variants next to it) builds the query as:
from c in ss.Set<Customer>().Include(c => c.Orders)
from o in ss.Set<Order>().Where(o => o.CustomerID == c.CustomerID)
.OrderBy(o => c.CustomerID).Take(5)
where c.CustomerID.StartsWith("F")
select c
c.CustomerID is constant inside the correlated subquery. Therefore ORDER BY c.CustomerID does not define a unique order of Orders, while Take(5) depends on which five rows the relational provider returns. LINQ-to-Objects uses a stable sort and picks the first five source rows; SQL does not guarantee that.
Why this is not a provider requirement
SQL-92 §13.1, General Rules, item 2:
If an
<order by clause>is not specified, then the table specified by the<cursor specification>is T and the ordering of rows in T is implementation-dependent.
SQL-92, Implementation-defined elements, item 14:
If the
<declare cursor>does not include an<order by clause>, or includes an<order by clause>that does not specify the order of the rows completely, then the rows of the table have an order that is defined only to the extent that the<order by clause>specifies an order and is otherwise implementation-dependent.
PostgreSQL documentation (SELECT, ORDER BY / LIMIT):
If they are equal according to all specified expressions, they are returned in an implementation-dependent order.
It is even possible for repeated executions of the same
LIMITquery to return different subsets of the rows of a table, if there is not anORDER BYto enforce selection of a deterministic subset. Again, this is not a bug; determinism of the results is simply not guaranteed in such a case.
Codd's relational model defines a relation as a set of n-tuples; a set has no intrinsic row order, and Codd explicitly lists ordering dependence as something applications must not rely on.
Observed effect
Against a relational provider whose engine does not guarantee stable ties, the first query can pick an arbitrary set of five OrderIDs. In split-query mode the included Orders collection is then not attached to the expected parent rows, and AssertIncludeCollection fails with e.g. Expected: 5, Actual: 0. The same query can also answer differently between executions.
Suggested fix
Make the test query deterministic by adding a unique tiebreaker:
.OrderBy(o => c.CustomerID).ThenBy(o => o.OrderID).Take(5)
or assert the included collection in an order-insensitive way. The test should not require a relational engine to reproduce LINQ-to-Objects' stable tie ordering.
This is a test-specification issue, not a requirement for providers to emulate LINQ stable sort.
- Ngôn ngữ chính
- C#
- Star
- 14.8k
- Fork
- 3.5k
- Merge trung bình
- 2 ngày 22 giờ
- Pull request đã merge (30 ngày)
- 158
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/efcore
-
customer-reported
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Compiled model: generate a deterministic model IDCó thể đã có người làm @rgroenewoudt đã nhận hôm nay. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
-
customer-reported
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/efcore
Issue tương tự
-
area-VM-meta-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/sqltoolsservice#2851 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
elsa-workflows/elsa-foundation#6322 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
mohebifar/made-in-iran#273 ·