In MySQL 8.0, when using invalid values for date data types, an error is returned. This was not the case in 5.x versions.
Let’s have a look using the table definition of bug 96361:
CREATE TABLE `new_table` (
`id_table` int(11) NOT NULL AUTO_INCREMENT,
`text_table` varchar(45) DEFAULT NULL,
`date_table` date DEFAULT NULL,
PRIMARY KEY (`id_table`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
Now we can try the following statement in MySQL 5.7 and MySQL 8.0:
MySQL 5.7.26> SELECT id_table, text_table
FROM new_table WHERE date_table = '' OR date_table IS NULL;
Empty set, 1 warning (0.01 sec)
MySQL 5.7.26> show warnings;
+---------+------+-----------------------------------------------------------+
| Level | Code | Message | …[Read more]