Check out the following SQL:
SELECT `g`.`Nickname`, COALESCE((
SELECT `t1`.`IssueDate`
FROM `Tags` AS `t1`
WHERE `t1`.`GearNickName` = `g`.`FullName`
ORDER BY `t1`.`Id`
LIMIT 1), '0001-01-01 00:00:00') AS `invalidTagIssueDate`
FROM `Gears` AS `g`
LEFT JOIN `Tags` AS `t` ON (`g`.`Nickname` = `t`.`GearNickName`) AND (`g`.`SquadId` = `t`.`GearSquadId`)
WHERE `t`.`IssueDate` > COALESCE((
SELECT `t0`.`IssueDate`
FROM `Tags` AS `t0`
WHERE `t0`.`GearNickName` = `g`.`FullName`
ORDER BY `t0`.`Id`
LIMIT 1), '0001-01-01 00:00:00')
It should return the following result set, with invalidTagIssueDate being of type datetime:
+------------+----------------------------+
| Nickname | invalidTagIssueDate |
+------------+----------------------------+
| Cole Train | 0001-01-01 00:00:00.000000 |
| Baird | 0001-01-01 00:00:00.000000 |
| Dom | 0001-01-01 00:00:00.000000 |
| Paduk | 0001-01-01 00:00:00.000000 |
| Marcus | 0001-01-01 00:00:00.000000 |
+------------+----------------------------+
5 rows in set (0.00 sec)
However, MySQL does not recognize, that the '0001-01-01 00:00:00' string is a datetime literal and just returns it as a string:
+------------+---------------------+
| Nickname | invalidTagIssueDate |
+------------+---------------------+
| Cole Train | 0001-01-01 00:00:00 |
| Baird | 0001-01-01 00:00:00 |
| Dom | 0001-01-01 00:00:00 |
| Paduk | 0001-01-01 00:00:00 |
| Marcus | 0001-01-01 00:00:00 |
+------------+---------------------+
5 rows in set (0.00 sec)
The result is, that when a System.DateTime is requested from the data reader, MySqlConnector throws.
It would therefore make sense, that MySqlConnector gracefully parses a string to a DateTime, if a DateTime is requested by the user, but a string returned by the database.
Otherwise, Pomelo would need to explicitly cast all datetime literals explicitly to datetime, which is probably fine for us.
But fixing this MySQL behavior in MySqlConnector would also solve the issue for non Pomelo users.
Check out the following SQL:
It should return the following result set, with
invalidTagIssueDatebeing of typedatetime:However, MySQL does not recognize, that the
'0001-01-01 00:00:00'string is adatetimeliteral and just returns it as a string:The result is, that when a
System.DateTimeis requested from the data reader, MySqlConnector throws.It would therefore make sense, that MySqlConnector gracefully parses a string to a
DateTime, if aDateTimeis requested by the user, but a string returned by the database.Otherwise, Pomelo would need to explicitly cast all datetime literals explicitly to
datetime, which is probably fine for us.But fixing this MySQL behavior in MySqlConnector would also solve the issue for non Pomelo users.