Skip to content

Conversation

Copy link

Copilot AI commented Dec 16, 2025

Two correlated collection tests were failing on MySQL 8.0.40 with Assert.Empty() Failure: Collection was not empty because SQL was being generated when tests expected none. MariaDB tests were skipped (OuterApply unsupported).

Root Cause

MySQL 8.0.14+ supports OUTER APPLY via LATERAL joins. The query translator generates valid SQL:

SELECT `c`.`CustomerID`, `s`.`First`, `s`.`Second`, `s`.`Third`
FROM `Customers` AS `c`
LEFT JOIN LATERAL (
    SELECT DISTINCT `o`.`OrderID` AS `First`, `o`.`OrderDate` AS `Second`, `c0`.`City` AS `Third`
    FROM `Orders` AS `o`
    LEFT JOIN `Customers` AS `c0` ON `o`.`CustomerID` = `c0`.`CustomerID`
    WHERE `c`.`CustomerID` = `o`.`CustomerID`
) AS `s` ON TRUE
ORDER BY `c`.`CustomerID`, `s`.`First`, `s`.`Second`

MariaDB never supports OuterApply (all versions), causing translation failures and test skips.

Changes

  • Added version-conditional SQL assertions using AppConfig.ServerVersion.Supports.OuterApply

    • MySQL 8.0.14+: Assert expected LATERAL SQL
    • MariaDB: Assert no SQL (tests skip on translation failure)
  • Updated tests:

    • Correlated_collection_with_distinct_without_default_identifiers_projecting_columns
    • Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation
if (AppConfig.ServerVersion.Supports.OuterApply)
{
    AssertSql(/* LATERAL SQL */);
}
else
{
    AssertSql(); // No SQL - will skip
}
Original prompt

This section details on the original issue you should resolve

<issue_title>Assert.Empty() Failure: Collection was not empty</issue_title>
<issue_description>With respect to the difference in MySQL and Mariadb, this is broken for MySQL v8.0.40, MariaDB 10.5.27, but it works in MariaDB 11.6.2:

Failed Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(async: False) [1 s]
Error Message:
Assert.Empty() Failure: Collection was not empty
Collection: ["SELECT c.CustomerID, s.First, s.Second"···]
Stack Trace:
at Microsoft.EntityFrameworkCore.TestUtilities.TestSqlLoggerFactory.AssertBaseline(String[] expected, Boolean assertOrder, Boolean forUpdate)
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.AssertSql(String[] expected) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs:line 7244
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(Boolean async) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs:line 6836
--- End of stack trace from previous location ---

Failed Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(async: True) [2 s]
Error Message:
Assert.Empty() Failure: Collection was not empty
Collection: ["SELECT c.CustomerID, s.First, s.Second"···]
Stack Trace:
at Microsoft.EntityFrameworkCore.TestUtilities.TestSqlLoggerFactory.AssertBaseline(String[] expected, Boolean assertOrder, Boolean forUpdate)
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.AssertSql(String[] expected) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs:line 7244
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.NorthwindMiscellaneousQueryMySqlTest.Correlated_collection_with_distinct_without_default_identifiers_projecting_columns_with_navigation(Boolean async) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/NorthwindMiscellaneousQueryMySqlTest.cs:line 6836
--- End of stack trace from previous location ---
```</issue_description>

<agent_instructions>restore, build, ensure database is running before testing, fix code, restest before committing</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…expectations for MySQL 8.0.14+

Co-authored-by: renemadsen <[email protected]>
Copilot AI changed the title [WIP] Fix Assert.Empty() failure in MySQL tests Fix Assert.Empty() failures for LATERAL join tests on MySQL 8.0.14+ Dec 16, 2025
Copilot AI requested a review from renemadsen December 16, 2025 09:56
@renemadsen renemadsen marked this pull request as ready for review December 16, 2025 10:35
@renemadsen renemadsen merged commit 731c2e9 into master Dec 16, 2025
24 of 55 checks passed
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.

Assert.Empty() Failure: Collection was not empty

2 participants