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.


You gotta love that "Automagic". I never knew about this, so thanks for sharing.

Personally, I'm beginning to hate cake's model/ORM. Whatever happened to good old SQL? It's more of standard then ORM will ever be. The amount of code you write binding and unbinding, you could have written with one SQL statement
-- George, 07 Mar 2008
George, which cake version are you using?

Can you paste your bind and unbind code here please?
-- Tim Koschuetzki, 07 Mar 2008

Post a comment

All comments are held for moderation; basic HTML formatting accepted.