[jifty-devel] Jifty::DBI quoting bug with PostgreSQL bool fields
jesse at bestpractical.com
Wed Sep 6 00:21:21 EDT 2006
On Tue, Sep 05, 2006 at 07:55:00AM -0400, Sean E. Millichamp wrote:
> 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 think this is a case of "Different databases define boolean operators
differently" Will everything always take unquoted true and false? I
think jifty::dbi may just need to be smarter about bool types, but I'd
be happiest if we can find a [database] platform-independent way to do it.
> 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.
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
More information about the jifty-devel