Properly throw on FC with find (it can never work anyway)
[dbsrgits/DBIx-Class.git] / t / row / filter_column.t
index 26631b4..10ac1a4 100644 (file)
@@ -259,4 +259,18 @@ throws_ok { DBICTest::Schema::Artist->filter_column( charfield => {} ) }
   'Correctly throws exception for empty attributes'
 ;
 
+FC_ON_PK_TEST: {
+
+  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;