[Bast-commits] r8929 - in DBIx-Class/0.08/branches/storage-interbase: . lib/DBIx/Class lib/DBIx/Class/Storage/DBI t

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sun Mar 7 10:46:02 GMT 2010


Author: caelum
Date: 2010-03-07 10:46:02 +0000 (Sun, 07 Mar 2010)
New Revision: 8929

Modified:
   DBIx-Class/0.08/branches/storage-interbase/Changes
   DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/SQLAHacks.pm
   DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
   DBIx-Class/0.08/branches/storage-interbase/t/750firebird.t
Log:
fix RETURNING for empty INSERT

Modified: DBIx-Class/0.08/branches/storage-interbase/Changes
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/Changes	2010-03-07 10:38:32 UTC (rev 8928)
+++ DBIx-Class/0.08/branches/storage-interbase/Changes	2010-03-07 10:46:02 UTC (rev 8929)
@@ -1,5 +1,6 @@
 Revision history for DBIx::Class
 
+        - Support for Firebird RDBMS with DBD::InterBase and ODBC
         - DBIx::Class::InflateColumn::File entered deprecated state
         - DBIx::Class::Optional::Dependencies left experimental state
         - Add req_group_list to Opt::Deps (RT#55211)

Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/SQLAHacks.pm	2010-03-07 10:38:32 UTC (rev 8928)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/SQLAHacks.pm	2010-03-07 10:46:02 UTC (rev 8929)
@@ -360,7 +360,14 @@
   # which is sadly understood only by MySQL. Change default behavior here,
   # until SQLA2 comes with proper dialect support
   if (! $_[0] or (ref $_[0] eq 'HASH' and !keys %{$_[0]} ) ) {
-    return "INSERT INTO ${table} DEFAULT VALUES"
+    my $sql = "INSERT INTO ${table} DEFAULT VALUES";
+
+    if (my @returning = @{ ($_[1]||{})->{returning} || [] }) {
+      $sql .= ' RETURNING (' . (join ', ' => map $self->_quote($_), @returning)
+            . ')';
+    }
+
+    return $sql;
   }
 
   $self->SUPER::insert($table, @_);

Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-03-07 10:38:32 UTC (rev 8928)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-03-07 10:46:02 UTC (rev 8929)
@@ -42,6 +42,7 @@
   if ($op eq 'insert') {
     $self->_auto_incs([]);
 
+    my %pk;
     @pk{$ident->primary_columns} = ();
 
     my @auto_inc_cols = grep {

Modified: DBIx-Class/0.08/branches/storage-interbase/t/750firebird.t
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/t/750firebird.t	2010-03-07 10:38:32 UTC (rev 8928)
+++ DBIx-Class/0.08/branches/storage-interbase/t/750firebird.t	2010-03-07 10:46:02 UTC (rev 8929)
@@ -14,7 +14,11 @@
 
 plan skip_all => <<'EOF' unless $dsn || $dsn2;
 Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN},
-_USER and _PASS to run these tests
+_USER and _PASS to run these tests.
+
+WARNING: this test creates and drops the tables "artist", "bindtype_test" and
+"sequence_test"; the generators "gen_artist_artistid", "pkid1_seq", "pkid2_seq"
+and "nonpkid_seq" and the trigger "artist_bi".
 EOF
 
 my @info = (
@@ -190,11 +194,20 @@
   }
 
 # test empty insert
+  lives_and {
+    my $row = $ars->create({});
+    ok $row->artistid;
+  } 'empty insert works';
+
+# test inferring the generator from the trigger source and using it with
+# auto_nextval
   {
-    local $ars->result_source->column_info('artistid')->{is_auto_increment} = 0;
+    local $ars->result_source->column_info('artistid')->{auto_nextval} = 1;
 
-    lives_ok { $ars->create({}) }
-      'empty insert works';
+    lives_and {
+      my $row = $ars->create({ name => 'introspecting generator' });
+      ok $row->artistid;
+    } 'inferring generator from trigger source works';
   }
 
 # test blobs (stolen from 73oracle.t)




More information about the Bast-commits mailing list