Reshape initial tests
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artist.pm
index dd5028e..4f2bde5 100644 (file)
@@ -30,7 +30,10 @@ __PACKAGE__->add_columns(
   },
 );
 __PACKAGE__->set_primary_key('artistid');
+__PACKAGE__->add_unique_constraint(['name']);
 __PACKAGE__->add_unique_constraint(artist => ['artistid']); # do not remove, part of a test
+__PACKAGE__->add_unique_constraint(u_nullable => [qw/charfield rank/]);
+
 
 __PACKAGE__->mk_classdata('field_name_for', {
     artistid    => 'primary key',
@@ -39,8 +42,23 @@ __PACKAGE__->mk_classdata('field_name_for', {
 
 __PACKAGE__->has_many(
     cds => 'DBICTest::Schema::CD', undef,
-    { order_by => 'year' },
+    { order_by => { -asc => 'year'} },
 );
+
+
+__PACKAGE__->has_many(
+    cds_80s => 'DBICTest::Schema::CD',
+    sub {
+        my ( $self_alias, $rel_alias, $self_rsrc, $rel_name ) = @_;
+        return {
+            "${rel_alias}.artist" => \ "${self_alias}.artistid",
+            "${rel_alias}.year"   => { '>', "1979" },
+            "${rel_alias}.year"   => { '<', "1990" }
+        };
+    }
+);
+
+
 __PACKAGE__->has_many(
     cds_unordered => 'DBICTest::Schema::CD'
 );