Skip to content

fix: restore old string translation from pomelo 8.0 - #361

Open
crjc wants to merge 1 commit into
microting:masterfrom
crjc:fix/issue-360
Open

crjc wants to merge 1 commit into
microting:masterfrom
crjc:fix/issue-360

Conversation

@crjc

@crjc crjc commented Jun 7, 2026

Copy link
Copy Markdown

Restores previous tostring query translation from older Pomelo versions. See #360

@renemadsen

Copy link
Copy Markdown
Member

@crjc tests are failing, so please do fix the failing tests, so we could merge the fix.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

It changes core query translation null semantics broadly (not just for Guid?) without a regression test covering #360, which may impact existing queries unexpectedly.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This PR restores the pre-Pomelo 9.x translation behavior for ToString() on non-string expressions by removing the COALESCE(..., '') wrapper, aligning generated SQL more closely with the Pomelo 8.0 output referenced in issue #360.

Changes:

  • Remove COALESCE around Convert(..., typeof(string)) in MySqlObjectToStringTranslator so nullable values translate to nullable string expressions.
  • Restore the older null-handling behavior for comparisons involving .ToString() in SQL translation (notably impacting Guid?).
File Description
src/​EFCore.MySql/​Query/​Internal/​MySqlObjectToStringTranslator.cs Removes COALESCE from the ToString() translation for supported CLR types to match Pomelo 8.0-style SQL output.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 92 to 95
// Enums are handled by EnumMethodTranslator.
return _supportedTypes.Contains(instance.Type)
? _sqlExpressionFactory.Coalesce(
_sqlExpressionFactory.Convert(instance, typeof(string)),
_sqlExpressionFactory.Constant(string.Empty))
? _sqlExpressionFactory.Convert(instance, typeof(string))
: null;
Comment on lines 93 to 95
return _supportedTypes.Contains(instance.Type)
? _sqlExpressionFactory.Coalesce(
_sqlExpressionFactory.Convert(instance, typeof(string)),
_sqlExpressionFactory.Constant(string.Empty))
? _sqlExpressionFactory.Convert(instance, typeof(string))
: null;
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