X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frow%2Ffilter_column.t;h=7823fa53e3bfc2b05a6374ad49e0005e4d8ae371;hb=2a7875330aa2f812eaa325ce69f0fa1c860771ac;hp=26631b44f3e6a29c09f914d15b5cfca6dfa5f9c3;hpb=cfa1ab03f5bdd0f14f4eaca99cd002be0020d001;p=dbsrgits%2FDBIx-Class.git diff --git a/t/row/filter_column.t b/t/row/filter_column.t index 26631b4..7823fa5 100644 --- a/t/row/filter_column.t +++ b/t/row/filter_column.t @@ -259,4 +259,30 @@ throws_ok { DBICTest::Schema::Artist->filter_column( charfield => {} ) } 'Correctly throws exception for empty attributes' ; +FC_ON_PK_TEST: { + # there are cases in the wild that autovivify stuff deep in the + # colinfo guts. While this is insane, there is no alternative + # so at leats make sure it keeps working... + + $schema->source('Artist')->column_info('artistid')->{_filter_info} ||= {}; + + for my $key ('', 'primary') { + lives_ok { + $schema->resultset('Artist')->find_or_create({ artistid => 42 }, { $key ? ( key => $key ) : () }); + }; + } + + + DBICTest::Schema::Artist->filter_column(artistid => { + filter_to_storage => sub { $_[1] * 100 }, + filter_from_storage => sub { $_[1] - 100 }, + }); + + for my $key ('', 'primary') { + throws_ok { + $schema->resultset('Artist')->find_or_create({ artistid => 42 }, { $key ? ( key => $key ) : () }); + } qr/\QUnable to satisfy requested constraint 'primary', FilterColumn values not usable for column(s): 'artistid'/; + } +} + done_testing;