I've run into a problem where I'm unable to set a default value for a boolean field when creating Oracle tables using Doctrine. The summary of this issue is that when Doctrine quotes a '0' or false value for a boolean field, it comes back blank... which doesn't work as an option for the DEFAULT parameter of field definitions in table creation.
Here are the hairy details. I have a schema which looks something like this (simplified for the example):
When I export the table, it's generating invalid DDL like this:
The important part of this is the DEFAULT parameter on the 'disabled' field definition – it's missing the value. I tracked all this down to an issue in Doctrine_Formatter->quote(), which gets called when the DDL is being created. When passed '0' as its input with a type of boolean, it apparently returns the empty string. This may ultimately be a bug in the PDO_OCI driver, because the quote method is relying on the quote method of the database handle.
I've hacked around this by overriding the behaviour of the quote method in Doctrine_Connection_Oracle. I did this by adding the following method:
It seems to work for me, but I'd appreciate it if wiser heads than me would take a look and see if this is a sign of some larger issue, and if the way I've fixed it seems appropriate. I also am unsure of how/if this needs to propogate to newer versions.