Add extra test blob type
[dbsrgits/DBIx-Class.git] / t / 73oracle.t
index ca373cb..45f6152 100644 (file)
@@ -359,6 +359,57 @@ sub _run_tests {
     $schema->storage->debug ($orig_debug);
   }}
 
+# test populate (identity, success and error handling)
+  my $art_rs = $schema->resultset('Artist');
+
+  my $seq_pos = $art_rs->get_column('artistid')->max;
+  ok($seq_pos, 'Starting with something in the artist table');
+
+
+  my $pop_rs = $schema->resultset('Artist')->search(
+    { name => { -like => 'pop_art_%' } },
+    { order_by => 'artistid' }
+  );
+
+  $art_rs->delete;
+  lives_ok {
+    $pop_rs->populate([
+      map { +{ name => "pop_art_$_" } }
+      (1,2,3)
+    ]);
+
+    is_deeply (
+      [ $pop_rs->get_column('artistid')->all ],
+      [ map { $seq_pos + $_ } (1,2,3) ],
+      'Sequence works after empty-table insertion'
+    );
+  } 'Populate without identity does not throw';
+
+  lives_ok {
+    $pop_rs->populate([
+      map { +{ artistid => $_, name => "pop_art_$_" } }
+      (1,2,3)
+    ]);
+
+    is_deeply (
+      [ $pop_rs->get_column('artistid')->all ],
+      [ 1,2,3, map { $seq_pos + $_ } (1,2,3) ],
+      'Explicit id population works'
+    );
+  } 'Populate with identity does not throw';
+
+  throws_ok {
+    $pop_rs->populate([
+      map { +{ artistid => $_, name => "pop_art_$_" } }
+      (200, 1, 300)
+    ]);
+  } qr/unique constraint.+populate slice.+name => "pop_art_1"/s, 'Partially failed populate throws';
+
+  is_deeply (
+    [ $pop_rs->get_column('artistid')->all ],
+    [ 1,2,3, map { $seq_pos + $_ } (1,2,3) ],
+    'Partially failed populate did not alter table contents'
+  );
 
 # test sequence detection from a different schema
   SKIP: {
@@ -480,7 +531,7 @@ sub do_creates {
   $dbh->do("CREATE TABLE ${q}track${q} (${q}trackid${q} NUMBER(12), ${q}cd${q} NUMBER(12) REFERENCES CD(${q}cdid${q}) DEFERRABLE, ${q}position${q} NUMBER(12), ${q}title${q} VARCHAR(255), ${q}last_updated_on${q} DATE, ${q}last_updated_at${q} DATE)");
   $dbh->do("ALTER TABLE ${q}track${q} ADD (CONSTRAINT ${q}track_pk${q} PRIMARY KEY (${q}trackid${q}))");
 
-  $dbh->do("CREATE TABLE ${q}bindtype_test${q} (${q}id${q} integer NOT NULL PRIMARY KEY, ${q}bytea${q} integer NULL, ${q}blob${q} blob NULL, ${q}clob${q} clob NULL)");
+  $dbh->do("CREATE TABLE ${q}bindtype_test${q} (${q}id${q} integer NOT NULL PRIMARY KEY, ${q}bytea${q} integer NULL, ${q}blob${q} blob NULL, ${q}clob${q} clob NULL, ${q}a_memo${q} integer NULL)");
 
   $dbh->do(qq{
     CREATE OR REPLACE TRIGGER ${q}artist_insert_trg_auto${q}