$VERSION = '0.08111';
Ok, starting simple, what's the correct way to store and retrieve dbic row
objects from Storable?
#!/usr/bin/perl
use warnings;
use strict;
use Storable;
use MyApp;
my $schema = MyApp->connect({ dsn => 'dbi:Pg:database=music' });
my $artist = $schema->resultset( 'Artist' )->find( 1 );
my @cds = $artist->cds;
warn "storing\n";
store { artist => $artist, }, 'stored';
warn "retrieve\n";
my $h = retrieve 'stored';
warn "calling ->cds on deserialized object\n";
$h->{artist}->cds;
Results in:
storing
retrieve
Unable to restore schema at ../../lib/Storable.pm (autosplit into
../../lib/auto/Storable/thaw.al) line 415
calling ->cds on deserialized object
Can't call method "source" on an undefined value at
/usr/local/share/perl/5.10.0/DBIx/Class/R
My Artist class uses this base class, although I get the same thing
regardless of including
Serialize::Storable.
package MyApp::Result;
use strict;
use warnings;
use base qw( DBIx::Class );
__PACKAGE__->load_components(qw/
Serialize::Storable
InflateColumn::DateTime
Core
/);
1;
FYI, here's the Artist class.
package MyApp::Result::Artist;
use strict;
use warnings;
use base 'MyApp::Result';
#__PACKAGE__->load_components("InflateColumn::DateTime", "Core");
__PACKAGE__->table("artist");
__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
default_value => "nextval('artist_id_seq'::regclass)",
is_auto_increment => 1,
is_nullable => 0,
size => 4,
},
"name",
{
data_type => "text",
default_value => undef,
is_nullable => 1,
size => undef,
},
"label",
{
data_type => "integer",
default_value => undef,
is_foreign_key => 1,
is_nullable => 0,
size => 4,
},
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("label", "MyApp::Result::Label", { id => "label" });
__PACKAGE__->has_many("cds", "MyApp::Result::Cd", { "foreign.artist" => "
self.id" });
# Created by DBIx::Class::Schema::Loader v0.04999_08 @ 2009-09-21 11:25:54
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VpcwTJEGCmz+LZCDMjwqqw
# You can replace this text with custom content, and it will be preserved on
regeneration
1;
--
Bill Moseley
[email protected]
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]