d258180665ea2138c8706bffc713fc7f2fd13312
[dbsrgits/DBIx-Class.git] / t / 19retrieve_on_insert.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use lib qw(t/lib);
7 use DBICTest;
8
9 my $schema = DBICTest->init_schema();
10 $schema->storage->sql_maker->quote_char('"');
11
12 my $rs = $schema->resultset ('Artist');
13
14 my $obj;
15 lives_ok { $obj = $rs->create ({ name => 'artistA' }) } 'Default insert successful';
16 is ($obj->rank, undef, 'Without retrieve_on_insert, check rank');
17
18 $rs->result_source->add_columns(
19     '+rank' => { retrieve_on_insert => 1 }
20 );
21
22 lives_ok { $obj = $rs->create ({ name => 'artistB' }) } 'Default insert successful';
23 is ($obj->rank, 13, 'With retrieve_on_insert, check rank');
24
25 done_testing;