[jifty-devel] Jifty::DBI quoting bug with PostgreSQL bool fields

Sean E. Millichamp sean at bruenor.org
Tue Sep 5 07:55:00 EDT 2006

I have not (and probably will not for a while) had the time to actually
find what is needed to fix this, but I thought I'd mention it if someone
else wants to look into it.  I should further state that I haven't even
confirmed if it is a Jifty bug or a Jifty::DBI bug.

I started testing against SQLite with a boolean column definition like

column enabled =>
	type is 'bool',
	default is '1';

This worked fine in SQLite, 'enabled' always defaulted to '1', which
resulted in returning 1, as expected, so things like:
if ( $record->enabled ) worked.

I switched my backend to PostgreSQL and things stopped working.  The SQL
that was constructed for Pg looked like:

create table foo ( enabled bool default 1 ); and I got:
ERROR:  column "enabled" is of type boolean but default expression is of
type integer
HINT:  You will need to rewrite or cast the expression.

For a column of type 'bool', Pg needs either 1 and 0 quoted, t and f
quoted, or will accept true and false unquoted.  I could find no way
within the column declaration to force Jifty to always quote the value.
It seems to assume numbers should never be quoted.

If I use t/f or true/false for my default value then things work with
PostgreSQL but break with SQLite since it really expects a number and
the return value does not end up evaluating to 1/0.  I ended up just
doing my testing/devel work always against Pg as a "quick fix" but
figured it should be addressed at some point.

I'll try to find the opportunity to write a test for it that shows the
problem but, again, I don't know when that will be.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20060905/3047fc8f/attachment.pgp

More information about the jifty-devel mailing list