[Bast-commits] r8596 - in
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage: . DBI
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Wed Feb 10 11:40:38 GMT 2010
Author: ribasushi
Date: 2010-02-10 11:40:37 +0000 (Wed, 10 Feb 2010)
New Revision: 8596
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/SQLite.pm
Log:
Consolidate last_insert_id handling with a fallback-attempt on DBI::last_insert_id
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC.pm 2010-02-10 00:46:43 UTC (rev 8595)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/ODBC.pm 2010-02-10 11:40:37 UTC (rev 8596)
@@ -21,15 +21,6 @@
}
}
-sub _dbh_last_insert_id {
- my ($self, $dbh, $source, $col) = @_;
-
- # punt: if there is no derived class for the specific backend, attempt
- # to use the DBI->last_insert_id, which may not be sufficient (see the
- # discussion of last_insert_id in perldoc DBI)
- return $dbh->last_insert_id(undef, undef, $source->from, $col);
-}
-
1;
=head1 NAME
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/SQLite.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/SQLite.pm 2010-02-10 00:46:43 UTC (rev 8595)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI/SQLite.pm 2010-02-10 11:40:37 UTC (rev 8596)
@@ -10,11 +10,6 @@
use File::Copy;
use File::Spec;
-sub _dbh_last_insert_id {
- my ($self, $dbh, $source, $col) = @_;
- $dbh->func('last_insert_rowid');
-}
-
sub backup
{
my ($self, $dir) = @_;
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2010-02-10 00:46:43 UTC (rev 8595)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2010-02-10 11:40:37 UTC (rev 8596)
@@ -2053,18 +2053,14 @@
=cut
sub _dbh_last_insert_id {
- # All Storage's need to register their own _dbh_last_insert_id
- # the old SQLite-based method was highly inappropriate
+ my ($self, $dbh, $source, $col) = @_;
- my $self = shift;
- my $class = ref $self;
- $self->throw_exception (<<EOE);
+ my $id = eval { $dbh->last_insert_id (undef, undef, $source->name, $col) };
-No _dbh_last_insert_id() method found in $class.
-Since the method of obtaining the autoincrement id of the last insert
-operation varies greatly between different databases, this method must be
-individually implemented for every storage class.
-EOE
+ return $id if defined $id;
+
+ my $class = ref $self;
+ $self->throw_exception ("No storage specific _dbh_last_insert_id() method implemented in $class, and the generic DBI::last_insert_id() failed");
}
sub last_insert_id {
More information about the Bast-commits
mailing list