8 my $schema = DBICTest->init_schema();
9 DBICTest::Schema::Artist->load_components('FilterColumn');
10 DBICTest::Schema::Artist->filter_column(rank => {
11 filter => sub { warn "FILTERING!"; $_[1] * 2 },
12 unfilter => sub {warn "UNFILTERING!"; $_[1] / 2 },
14 Class::C3->reinitialize();
16 my $artist = $schema->resultset('Artist')->create( { rank => 20 } );
18 # this should be using the cursor directly, no inflation/processing of any sort
19 my ($raw_db_rank) = $schema->resultset('Artist')
20 ->search ($artist->ident_condition)
26 is ($raw_db_rank, 10, 'INSERT: correctly unfiltered on insertion');
28 for my $reloaded (0, 1) {
29 my $test = $reloaded ? 'reloaded' : 'stored';
30 $artist->discard_changes if $reloaded;
32 is( $artist->rank , 20, "got $test filtered rank" );
36 $artist->discard_changes;
37 is( $artist->rank , 20, "got filtered rank" );
39 $artist->update ({ rank => 40 });
40 ($raw_db_rank) = $schema->resultset('Artist')
41 ->search ($artist->ident_condition)
46 is ($raw_db_rank, 20, 'UPDATE: correctly unflitered on update');
48 $artist->discard_changes;
50 ok( !$artist->is_column_changed('rank'), 'column is not dirty after setting the same value' );