Bug #104919 | MySQLCollateExpression.cs is causing EFCore to throw InvalidOperationException | ||
---|---|---|---|
Submitted: | 13 Sep 2021 4:39 | Modified: | 8 Mar 2024 1:56 |
Reporter: | Shiyao Wang (OCA) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / NET | Severity: | S1 (Critical) |
Version: | MySql.EntityFrameworkCore 5.0.5 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | EFCore, EntityFrameworkCore, MySql.EntityFrameworkCore, MySQLCollateExpression |
[13 Sep 2021 4:39]
Shiyao Wang
[13 Sep 2021 4:41]
Shiyao Wang
1_SQLExpressionTree.png
Attachment: 1_SQLExpressionTree.png (image/png, text), 70.11 KiB.
[13 Sep 2021 4:41]
Shiyao Wang
2_BuildSQL.png
Attachment: 2_BuildSQL.png (image/png, text), 30.82 KiB.
[13 Sep 2021 4:41]
Shiyao Wang
3_UnknownExpression.png
Attachment: 3_UnknownExpression.png (image/png, text), 114.85 KiB.
[13 Sep 2021 4:42]
Shiyao Wang
4_ExceptionThrown.png
Attachment: 4_ExceptionThrown.png (image/png, text), 33.31 KiB.
[13 Sep 2021 4:43]
Shiyao Wang
5_SQLExpressionTreeRealSQL.png
Attachment: 5_SQLExpressionTreeRealSQL.png (image/png, text), 31.35 KiB.
[13 Sep 2021 4:45]
Shiyao Wang
SQL Statements that creates a sample table to repro this bug
Attachment: BugRepro-SQL.sql (application/octet-stream, text), 203 bytes.
[13 Sep 2021 4:46]
Shiyao Wang
Sample C# code that can repro this bug
Attachment: BugRepro-CSharp.cs (text/plain), 896 bytes.
[13 Sep 2021 5:59]
Shiyao Wang
I tried my suggested fix, it is working OK. Here's the SQL from the log: ``` SQL SELECT COUNT(*) FROM `SampleTable` AS `s` WHERE (`s`.`SampleColumn` LIKE CONCAT('a', '%')) AND (LEFT(`s`.`SampleColumn`, CHAR_LENGTH(CONVERT('a' USING utf8mb4) COLLATE utf8mb4_bin)) = CONVERT('a' USING utf8mb4) COLLATE utf8mb4_bin) ```
[13 Sep 2021 6:53]
Shiyao Wang
I submitted a pull request to fix this. https://github.com/mysql/mysql-connector-net/pull/42
[13 Sep 2021 7:33]
MySQL Verification Team
Hello! Thank you for the report and test case. regards, Umesh
[8 Mar 2024 1:56]
Shiyao Wang
This bug is so old. I believe it's not there any more.