MySqlConnector: [Regression] Commit e70dda2 broke a Pomelo.MySql test
The following test in the GearsOfWarQueryTestBase
class worked before the e70dda2 commit:
[ConditionalFact]
public virtual void Select_null_conditional_with_inheritance_negative()
{
using (var context = CreateContext())
{
var query = context.Factions
.Where(f => f is LocustHorde)
.Select(f => EF.Property<string>((LocustHorde)f, "CommanderName") != null
? ((LocustHorde)f).Eradicated
: null);
var result = query.ToList();
Assert.Equal(2, result.Count);
Assert.True(result.Contains(true));
Assert.True(result.Contains(false));
}
}
It generates the following SQL:
SELECT CASE
WHEN `f`.`CommanderName` IS NOT NULL THEN `f`.`Eradicated`
ELSE NULL
END
FROM `Factions` AS `f`
WHERE (`f`.`Discriminator` = 'LocustHorde') AND (`f`.`Discriminator` = 'LocustHorde')
With the Fractions
table defined like this:
CREATE TABLE `Factions` (
`Id` int(11) NOT NULL,
`Name` longtext,
`CapitalName` varchar(255) DEFAULT NULL,
`Discriminator` longtext NOT NULL,
`CommanderName` varchar(255) DEFAULT NULL,
`Eradicated` bit(1) DEFAULT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `IX_Factions_CommanderName` (`CommanderName`),
KEY `IX_Factions_CapitalName` (`CapitalName`),
CONSTRAINT `FK_Factions_Cities_CapitalName` FOREIGN KEY (`CapitalName`) REFERENCES `cities` (`Name`) ON DELETE RESTRICT,
CONSTRAINT `FK_Factions_LocustLeaders_CommanderName` FOREIGN KEY (`CommanderName`) REFERENCES `locustleaders` (`Name`) ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Now it throws the following exception:
[xUnit.net 00:05:05.16] Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.GearsOfWarQueryMySqlTest.Select_null_conditional_with_inheritance_negative [FAIL]
X Pomelo.EntityFrameworkCore.MySql.FunctionalTests.Query.GearsOfWarQueryMySqlTest.Select_null_conditional_with_inheritance_negative [9ms]
Error Message:
System.FormatException : One of the identified items was in an invalid format.
Stack Trace:
at MySqlConnector.Core.Row.ParseUInt64(ReadOnlySpan`1 data) in C:\projects\mysqlconnector\src\MySqlConnector\Core\Row.cs:line 460
at MySqlConnector.Core.Row.ReadBit(ReadOnlySpan`1 data, ColumnFlags columnFlags) in C:\projects\mysqlconnector\src\MySqlConnector\Core\Row.cs:line 450
at MySqlConnector.Core.TextRow.GetValueCore(ReadOnlySpan`1 data, ColumnDefinitionPayload columnDefinition) in C:\projects\mysqlconnector\src\MySqlConnector\Core\TextRow.cs:line 109
at MySqlConnector.Core.Row.GetValue(Int32 ordinal) in C:\projects\mysqlconnector\src\MySqlConnector\Core\Row.cs:line 32
at MySqlConnector.Core.Row.GetBoolean(Int32 ordinal) in C:\projects\mysqlconnector\src\MySqlConnector\Core\Row.cs:line 67
at lambda_method(Closure , QueryContext , DbDataReader , ResultContext , Int32[] , ResultCoordinator )
at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.QueryingEnumerable`1.Enumerator.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Query.GearsOfWarQueryTestBase`1.Select_null_conditional_with_inheritance_negative()
Which happens at the following line, that was added in e70dda2: https://github.com/mysql-net/MySqlConnector/blob/9b8f3a4d8259144b52990d804f1dca303314289f/src/MySqlConnector/Core/Row.cs#L453-L454
So this column is likely the issue:
`Eradicated` bit(1) DEFAULT NULL
Of 13681 executed tests, this is the only one suddenly failing.
See https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/pull/849 for the full CI output.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (17 by maintainers)
Commits related to this issue
- Work around server bug reading BIT column. Fixes #713 — committed to mysql-net/MySqlConnector by bgrainger 5 years ago
- Work around server bug reading BIT column. Fixes #713 — committed to mysql-net/MySqlConnector by bgrainger 5 years ago
- Update MySqlConnector version to workaround MySQL regression. See https://github.com/mysql-net/MySqlConnector/issues/713 — committed to lauxjpn/Pomelo.EntityFrameworkCore.MySql by lauxjpn 5 years ago
- Update MySqlConnector version to workaround MySQL regression. See https://github.com/mysql-net/MySqlConnector/issues/713 — committed to lauxjpn/Pomelo.EntityFrameworkCore.MySql by lauxjpn 5 years ago
- Prepare dependencies for 3.0.0-rc1-final and fix remaining tests (#849) * Update dependencies to their latest stable version. * Reenable tests, that were previously blocked by MySqlConnector. *... — committed to PomeloFoundation/Pomelo.EntityFrameworkCore.MySql by lauxjpn 5 years ago
I was planning to report it (later).