Skip Menu |

This queue is for tickets about the CatalystX-ListFramework-Builder CPAN distribution.

Report information
The Basics
Id: 42352
Status: resolved
Priority: 0/
Queue: CatalystX-ListFramework-Builder

People
Owner: OLIVER [...] cpan.org
Requestors: LEEDO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Uses 'true' and 'false' for booleans instead of 1 and 0
When I use the data_type of BOOLEAN on my DBIx::Class schemas it generates SQL that expects either 1 or 0 for that column. E.g. on MySQL it creates an enum that only accepts 1 or 0. When I try to add a row with this module it attempts to use 'true' or 'false' for the BOOLEAN column. This works with SQLite's boolean column, but SQLite doesn't seem very picky. It is making some parts of my project difficult to code because I am constantly having to test for 'true' or 1. I have a patch locally, but it is so simple I don't know that it is worth posting.
I've attached my patch. I had to make some changes in the _build_table_data function because it was treating the 0 value as false.
--- /Users/leedo/AJAX.pm 2009-01-11 12:35:09.000000000 -0600 +++ AJAX.pm 2009-01-16 14:18:01.000000000 -0600 @@ -39,8 +39,8 @@ }, to_db => sub { my $val = shift; - return 'true' if $val eq 'on' or $val eq '1'; - return 'false'; + return 1 if $val eq 'on' or $val eq '1'; + return 0; }, }, ); @@ -286,7 +286,12 @@ ); } - $data->{$col} = $params->{ $prefix . $col } || undef; + if ($params->{$prefix . $col} or $params->{$prefix . $col} == 0) { + $data->{$col} = $params->{$prefix . $col}; + } + else { + $data->{$col} = undef; + } } } }
Hi Lee, On Tue Jan 13 00:10:49 2009, LEEDO wrote: Show quoted text
> When I use the data_type of BOOLEAN on my DBIx::Class schemas it > generates SQL that expects > either 1 or 0 for that column.
Thanks for the bug report and the patch (which does help, even though it's fairly trivial - gives me less reason to delay a new release!). I hope to incorporate this, test it, and release to CPAN this weekend. I'll leave this ticket open until then. Many thanks once again, oliver.
On Tue Jan 13 00:10:49 2009, LEEDO wrote: Show quoted text
> When I use the data_type of BOOLEAN on my DBIx::Class schemas it > generates SQL that expects > either 1 or 0 for that column.
Patch belatedly applied, new release to CPAN shortly. Many thanks once again,