by ars · 14y ago · 0 comments
mysql> insert into demo values ('y', 'y');
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> show warnings;
+---------+------+------------------------------------------------------+
| Level | Code | Message |
+---------+------+------------------------------------------------------+
| Warning | 1366 | Incorrect integer value: 'y' for column 'n' at row 1 |
+---------+------+------------------------------------------------------+
If you want this type of warning to be treated as an error then adjust the setting: mysql> SET sql_mode = 'TRADITIONAL';
mysql> insert into demo values ('y', 'y');
ERROR 1366 (HY000): Incorrect integer value: 'y' for column 'n' at row 1MySQL chose to coerce fields to fit the type. You don't like that choice, but other people find it useful. And MySQL gives you a choice to change it if you wish.
Judging by how popular and successful they are I think those chose correctly.
This article is a failure story for maciej. MySQL may have chosen correctly for its own popularity (although that's debatable; this choice might not be a success factor) but it did not choose correctly for the success of its users, with this article being a clear example.
Attributing their success to their choice of DB is insulting at best.
The coercing bin('y') to 0 makes no sense though - I agree with you there.