View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Robert Stone > DBIx-Class-InflateColumn-Time-0.0.1 > DBIx::Class::InflateColumn::Time



Annotate this POD


View/Report Bugs
Module Version: 0.0.1   Source  


DBIx::Class::InflateColumn::Time - Inflate and Deflate "time" columns into DateTime::Duration Objects


    package HorseTrack::Database::Schema::Result::Race;
    use base 'DBIx::Class::Core';

    use strict;
    use warnings;


        race_number => { data_type => 'integer'},
        duration    => { data_type => 'time'},


This module can be used to automagically inflate database columns of data type "time" into DateTime::Duration objects. It is used similiar to other InflateColumn DBIx modules.

Once your Result is properly defined you can now pass DateTime::Duration objects into columns of data_type time and retrieve DateTime::Duration objects from these columns as well


Inflation occurs whenever the data is being taken FROM the database. In this case the database is storing the value with data_type of time, upon inflation a DateTime::Duration object is returned from the resultset.

    package HorseTrack::Race;

    use strict;
    use warnings;

    use Moose;
    use namespace::autoclean;

    use DateTime::Duration;

    has 'race_number' => ( is => 'rw', isa => 'Int' );
    has 'duration'    => ( is => 'rw', isa => 'DateTime::Duration' );

    sub retrieve {
        my $self = shift;

        my $result = $schema->resultset('...')->search({ race_number => 1 })->single;

        my $race = $self->new({
            race_number => $result->race_number,
            duration    => $result->duration,

        return $race;



Deflation occurs whenever the data is being taken TO the database. In this case an object of type DateTime::Duration is being stored into the a database columns with a data_type of "time". Using the same object from the Inflation example:

        race_number => $self->race_number,
        duration    => $self->duration,


Strictly speaking, you don't actually call any of these methods yourself. DBIx handles the magic provided you have included the InflateColumn::Time component in your Result.

Therefore, there are no public methods to be consumed.


Robert Stone <drzigman AT cpan DOT org >


Copyright 2013 Robert Stone

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU Lesser General Public License as published by the Free Software Foundation; or any compatible license.

See for more information.

syntax highlighting: