[Dbix-class] get_inflated_columns and selecting specific columns

Ronald J Kimball rkimball+dbixclass at pangeamedia.com
Wed Aug 13 16:26:59 BST 2008


With search(), you can specify a set of columns to return, e.g.:
   select => [qw/ item_id name /],

However, unlike get_columns(), get_inflated_columns() doesn't limit 
itself to those columns.  Instead, it returns values for all the columns 
in the table.  Of course, the value will beundef for any columns that 
weren't actually selected.

Is this the intended behavior?  It isn't clear to me from the documentation.

I'm using DBIx::Class 0.08007.

Example below.

thanks,
Ronald


#!/usr/bin/perl

use strict;
use warnings;

use TestApp::Model::TestDB;

use Data::Dump qw/ dump /;

my $schema = TestApp::Model::TestDB->new();

my $test_items_rs = $schema->resultset('TestItem');

while (my $test_item = $test_items_rs->next) {
   print dump({ $test_item->get_columns }), "\n";
   print dump({ $test_item->get_inflated_columns }), "\n";
}

print "\n";

$test_items_rs =
   $test_items_rs->search(undef, { select => [qw/ item_id name /] });

while (my $test_item = $test_items_rs->next) {
   print dump({ $test_item->get_columns }), "\n";
   print dump({ $test_item->get_inflated_columns }), "\n";
}
__END__

{ info => "This is the first item", item_id => 0, name => "Item One" }
{ info => "This is the first item", item_id => 0, name => "Item One" }

{ item_id => 0, name => "Item One" }
{ info => undef, item_id => 0, name => "Item One" }



More information about the DBIx-Class mailing list