From bef210836e0dcecc0e5ebae93bae848c58cb50cc Mon Sep 17 00:00:00 2001
From: Andrew Yates <ayates@ebi.ac.uk>
Date: Mon, 21 May 2012 13:40:46 +0000
Subject: [PATCH] Adding support for manual table but also added a MySQL mode
 which just ignores any parameter

---
 modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm
index aa69355d1f..e173cf2d41 100755
--- a/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm
+++ b/modules/Bio/EnsEMBL/DBSQL/BaseAdaptor.pm
@@ -687,6 +687,8 @@ sub fetch_all {
                 into
   Arg [2]     : (optional) HashRef used to pass extra attributes through to the 
                 DBD driver
+  Arg [3]     : (optional) $table the name of the table to use if the adaptor
+                does not implement C<_tables()>
   Description : Delegating method which uses DBI to extract the last inserted 
                 identifier. If using MySQL we just call the DBI method 
                 L<DBI::last_insert_id()> since MySQL ignores any extra
@@ -698,11 +700,16 @@ sub fetch_all {
 =cut
 
 sub last_insert_id {
-  my ($self, $field, $attributes) = @_;
+  my ($self, $field, $attributes, $table) = @_;
   my $dbc = $self->dbc();
   my $dbh = $dbc->db_handle();
+  if($dbc->driver() eq 'mysql') {
+    return $dbh->last_insert_id();
+  }
   $attributes ||= {};
-  my ($table) = $self->_tables();
+  if(!$table) {
+    ($table) = $self->_tables();
+  }
   return $dbh->last_insert_id(undef, $dbc->dbname(), $table->[0], $field, $attributes);
 }
 
-- 
GitLab