add TODO on constraint check
[dbsrgits/DBIx-Class.git] / t / cdbi-t / 19-set_sql.t
index 2278cd4..f725c89 100644 (file)
@@ -2,8 +2,13 @@ use strict;
 use Test::More;
 
 BEGIN {
-       eval "use DBD::SQLite";
-       plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 17);
+  eval "use DBIx::Class::CDBICompat;";
+  if ($@) {
+    plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required');
+    next;
+  }
+  eval "use DBD::SQLite";
+  plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 20);
 }
 
 use lib 't/testlib';
@@ -14,6 +19,11 @@ use Actor;
        my @cols = Film->columns('Essential');
        is_deeply \@cols, ['title'], "1 Column in essential";
        is +Film->transform_sql('__ESSENTIAL__'), 'title', '__ESSENTIAL__ expansion';
+       
+       # This provides a more interesting test
+       Film->columns(Essential => qw(title rating));
+       is +Film->transform_sql('__ESSENTIAL__'), 'title, rating',
+           'multi-col __ESSENTIAL__ expansion';
 }
 
 my $f1 = Film->create({ title => 'A', director => 'AA', rating => 'PG' });
@@ -62,8 +72,22 @@ Film->set_sql(
        is $pgs[1]->id, $f4->id, "and F4";
 };
 
-SKIP: {
-  skip "DBIx::Class doesn't have has_a yet", 6;
+{
+    Film->set_sql(
+        by_id => qq{
+            SELECT  __ESSENTIAL__
+            FROM    __TABLE__
+            WHERE   __IDENTIFIER__
+        }
+    );
+    
+    my $film = Film->retrieve_all->first;
+    my @found = Film->search_by_id($film->id);
+    is @found, 1;
+    is $found[0]->id, $film->id;
+}
+
+
 {
        Actor->has_a(film => "Film");
        Film->set_sql(
@@ -106,4 +130,3 @@ SKIP: {
        is $apg[1]->title, "B", "and B";
 }
 
-} # end SKIP block