DBIx::Class::InflateColumn::Boolean Build Status

Perl does not have a native boolean data type by itself, it takes certain several scalar values as false (like '', 0, 0.0) as well as empty lists and undef, and everything else is true. It is also possible to set the boolean value of an object instance.

As in most program code you have boolean data in nearly every database. But for a database it is up to the designer to decide what is true and what is false.

This module maps such "database booleans" into "Perl booleans" and back by inflating designated columns into objects, that store the original value, but also evaluate as true or false in boolean context. Therefore - if "Yes" in the database means true and "No" means false in the application the following two lines can virtually mean the same:

if ($table->field eq "No") { ... }
if (not $table->field) { ... }

That means that $table->field has the scalar value "No", but is taken as false in a boolean context, whereas Perl would normally regard the string "No" as true.

When writing to the database, of course $table->field would be deflated to the original value "No" and not some Perlish form of a boolean.

Installation

Stable releases are available from the CPAN.

You can use cpanm to install from the command line:

$ cpanm DBIx::Class::InflateColumn::Boolean

More Information

Please look at the manpage.