8 my $schema = DBICTest->init_schema();
13 { module => 'YAML.pm',
14 inflater => sub { YAML::Load (shift) },
15 deflater => sub { die "Expecting a reference" unless (ref $_[0]); YAML::Dump (shift) },
17 { module => 'Storable.pm',
18 inflater => sub { Storable::thaw (shift) },
19 deflater => sub { die "Expecting a reference" unless (ref $_[0]); Storable::nfreeze (shift) },
25 foreach my $serializer (@serializers) {
26 eval { require $serializer->{module} };
28 $selected = $serializer;
33 plan (skip_all => "No suitable serializer found") unless $selected;
36 DBICTest::Schema::Serialized->inflate_column( 'serialized',
37 { inflate => $selected->{inflater},
38 deflate => $selected->{deflater},
41 Class::C3->reinitialize;
63 my $rs = $schema->resultset('Serialized');
64 my $entry = $rs->create({ id => 1, serialized => ''});
68 ok($entry->update ({ %{$complex1} }), 'hashref deflation ok');
69 ok($inflated = $entry->serialized, 'hashref inflation ok');
70 is_deeply($inflated, $complex1->{serialized}, 'inflated hash matches original');
72 my $entry2 = $rs->create({ id => 2, serialized => ''});
74 eval { $entry2->set_inflated_column('serialized', $complex1->{serialized}) };
75 ok(!$@, 'set_inflated_column to a hashref');
77 is_deeply($entry2->serialized, $complex1->{serialized}, 'inflated hash matches original');
79 ok($entry->update ({ %{$complex2} }), 'arrayref deflation ok');
80 ok($inflated = $entry->serialized, 'arrayref inflation ok');
81 is_deeply($inflated, $complex2->{serialized}, 'inflated array matches original');