--- ---

When is a TINYINT(1) not a TINYINT(1)?

When you're using CakePHP!

Turns out CakePHP considers a TINYINT(1) to be a Boolean. Judging from all the support tickets that have been filed, I'm not the first person to get taken off guard by this behavior. When I asked about it on IRC, the response was that since MySQL considers a TINYINT(1) to be a Boolean, CakePHP does too. That's not true.

From the MySQL manual:

As of MySQL 5.0.3, a BIT data type is available for storing bit-field values. (Before 5.0.3, MySQL interprets BIT as TINYINT(1).)

That's saying if I request a BIT it will make it a TINYINT, not if I request a TINYINT it will make it a BIT. Having a framework change the definitions of my database columns sounds crazy to me, but judging from the ticket filed in 2006 this has been CakePHP's policy for a long time. Despite the long standing precedent I can't find any documentation about it online other than the closing remarks of those support tickets.

This is a static site. If you have any comments please start a thread in the fediverse and tag me or send an email.