Unbreak $rs->create() with empty hashref on Oracle
[dbsrgits/DBIx-Class.git] / t / 73oracle.t
index fc324c5..87be799 100644 (file)
@@ -9,7 +9,6 @@ use DBIx::Class::Optional::Dependencies ();
 
 use lib qw(t/lib);
 use DBICTest;
-use DBIC::SqlMakerTest;
 
 my ($dsn,  $user,  $pass)  = @ENV{map { "DBICTEST_ORA_${_}" }  qw/DSN USER PASS/};
 
@@ -201,6 +200,12 @@ sub _run_tests {
     like ($seq, qr/\.${q}artist_pk_seq${q}$/, 'Correct PK sequence selected for sqlt-like trigger');
   }
 
+  lives_ok {
+    $new = $schema->resultset('Artist')->create({});
+    $new->discard_changes;
+    ok $new->artistid, 'Created row has id'
+  } 'Create with empty hashref works';
+
 
 # test LIMIT support
   for (1..6) {
@@ -488,7 +493,7 @@ sub _run_tests {
     # create identically named tables/sequences in the other schema
     do_creates($dbh2, $q);
 
-    # grand select privileges to the 2nd user
+    # grant select privileges to the 2nd user
     $dbh->do("GRANT INSERT ON ${q}artist${q} TO " . uc $user2);
     $dbh->do("GRANT SELECT ON ${q}artist${q} TO " . uc $user2);
     $dbh->do("GRANT SELECT ON ${q}artist_pk_seq${q} TO " . uc $user2);
@@ -551,6 +556,26 @@ sub _run_tests {
     do_clean ($dbh2);
   }}
 
+# test driver determination issues that led to the diagnosis/fix in 37b5ab51
+# observed side-effect when count-is-first on a fresh env-based connect
+  {
+    local $ENV{DBI_DSN};
+    ($ENV{DBI_DSN}, my @user_pass_args) = @{ $schema->storage->connect_info };
+    my $s2 = DBICTest::Schema->connect( undef, @user_pass_args );
+    ok (! $s2->storage->connected, 'Not connected' );
+    is (ref $s2->storage, 'DBIx::Class::Storage::DBI', 'Undetermined driver' );
+
+    ok (
+      $s2->resultset('Artist')->search({ 'me.name' => { like => '%' } }, { prefetch => 'cds' })->count,
+      'Some artist count'
+    );
+    ok (
+      scalar $s2->resultset('CD')->search({}, { join => 'tracks' } )->all,
+      'Some cds returned'
+    );
+    $s2->storage->disconnect;
+  }
+
   do_clean ($dbh);
 }