Skip to content

Conversation

Copy link

Copilot AI commented Dec 14, 2025

Description

The test Project_nullable_struct_complex_type_via_optional_navigation had an empty AssertSql() call but EF Core was generating valid SQL for projecting nullable struct complex types via optional navigation, causing the assertion to fail.

Changes

Updated the test baseline to match the generated SQL:

SELECT `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, 
       `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, 
       `v0`.`ShippingAddress_Country_FullName`
FROM `ValuedCustomerGroup` AS `v`
LEFT JOIN `ValuedCustomer` AS `v0` ON `v`.`OptionalCustomerId` = `v0`.`Id`

The SQL correctly handles nullable struct projections through LEFT JOIN, consistent with similar tests for non-nullable structs (line 478) and reference complex types (line 88).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix Assert.Empty() Failure: Collection was not empt</issue_title>
<issue_description>```
Failed Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.ComplexTypeQueryMySqlTest.Project_nullable_struct_complex_type_via_optional_navigation(async: False) [605 ms]
Error Message:
Assert.Empty() Failure: Collection was not empty
Collection: ["SELECT v0.`ShippingAddress_AddressLine1`, `v0`.`"···]
Stack Trace:
at Microsoft.EntityFrameworkCore.TestUtilities.TestSqlLoggerFactory.AssertBaseline(String[] expected, Boolean assertOrder, Boolean forUpdate)
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.ComplexTypeQueryMySqlTest.AssertSql(String[] expected) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs:line 1144
at Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.ComplexTypeQueryMySqlTest.Project_nullable_struct_complex_type_via_optional_navigation(Boolean async) in /home/runner/work/Pomelo.EntityFrameworkCore.MySql/Pomelo.EntityFrameworkCore.MySql/test/EFCore.MySql.FunctionalTests/Query/ComplexTypeQueryMySqlTest.cs:line 1136
--- End of stack trace from previous location ---
Standard Output Messages:
---- New Baseline -------------------------------------------------------------------
AssertSql(
"""
SELECT `v0`.`ShippingAddress_AddressLine1`, `v0`.`ShippingAddress_AddressLine2`, `v0`.`ShippingAddress_ZipCode`, `v0`.`ShippingAddress_Country_Code`, `v0`.`ShippingAddress_Country_FullName`
FROM `ValuedCustomerGroup` AS `v`
LEFT JOIN `ValuedCustomer` AS `v0` ON `v`.`OptionalCustomerId` = `v0`.`Id`
""");


<agent_instructions>restore nuget, build, ensture mariadb 11.6.2 is running before running any test. Run the single test, update expected sql to match the new data structure and actual sql and run the single test before committing. Run tests in same namespace to find similar issues.</agent_instructions>

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

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix Assert.Empty() failure in ComplexTypeQueryMySqlTest Fix Assert.Empty() failure in Project_nullable_struct_complex_type_via_optional_navigation test Dec 14, 2025
Copilot AI requested a review from renemadsen December 14, 2025 09:46
@renemadsen
Copy link
Member

@copilot Search for other tests where there is only AssertSql();, run those single tests to see if they also needs an update. Remeber to start mariadb 11.6.2 before running the tests.

Copy link
Author

Copilot AI commented Dec 14, 2025

@copilot Search for other tests where there is only AssertSql();, run those single tests to see if they also needs an update. Remeber to start mariadb 11.6.2 before running the tests.

I searched for all tests with empty AssertSql() in ComplexTypeQueryMySqlTest and found 7 tests:

  1. Subquery_over_complex_type
  2. Concat_two_different_complex_type
  3. Union_two_different_complex_type
  4. Subquery_over_struct_complex_type
  5. Concat_two_different_struct_complex_type
  6. Union_two_different_struct_complex_type
  7. Same_complex_type_projected_twice_with_pushdown_as_part_of_another_projection

I started MariaDB 11.6.2 and ran each test individually. All of them are passing correctly with empty AssertSql(). These tests are expected to have empty assertions because they don't generate SQL (likely throw exceptions or are unsupported operations). The test I fixed earlier (Project_nullable_struct_complex_type_via_optional_navigation) was different - it was actually generating valid SQL but had an incorrect empty baseline.

All 145 tests in ComplexTypeQueryMySqlTest now pass (with 3 skipped tests that aren't implemented in the base class yet).

@renemadsen renemadsen marked this pull request as ready for review December 14, 2025 10:19
@renemadsen renemadsen merged commit 81d2f8e into master Dec 14, 2025
2 of 56 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.

Fix Assert.Empty() Failure: Collection was not empt

2 participants