[Storage::DBI::InterBase] remove more cruft
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / InterBase.pm
1 package DBIx::Class::Storage::DBI::InterBase;
2
3 # mostly stolen from DBIx::Class::Storage::DBI::MSSQL
4
5 use strict;
6 use warnings;
7
8 use base qw/DBIx::Class::Storage::DBI/;
9 use mro 'c3';
10
11 use List::Util();
12
13 __PACKAGE__->mk_group_accessors(simple => qw/
14   _identity
15 /);
16
17 sub insert_bulk {
18   my $self = shift;
19   my ($source, $cols, $data) = @_;
20
21   my $is_identity_insert = (List::Util::first
22       { $source->column_info ($_)->{is_auto_increment} }
23       (@{$cols})
24   )
25      ? 1
26      : 0;
27
28   $self->next::method(@_);
29 }
30
31
32 sub _prep_for_execute {
33   my $self = shift;
34   my ($op, $extra_bind, $ident, $args) = @_;
35
36   my ($sql, $bind) = $self->next::method (@_);
37
38   if ($op eq 'insert') {
39     $sql .= 'RETURNING "Id"';
40
41   }
42
43   return ($sql, $bind);
44 }
45
46 sub _execute {
47   my $self = shift;
48   my ($op) = @_;
49
50   my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
51
52   if ($op eq 'insert') {
53
54     # this should bring back the result of SELECT SCOPE_IDENTITY() we tacked
55     # on in _prep_for_execute above
56     local $@;
57     my ($identity) = eval { $sth->fetchrow_array };
58
59     $self->_identity($identity);
60     $sth->finish;
61   }
62
63   return wantarray ? ($rv, $sth, @bind) : $rv;
64 }
65
66 sub last_insert_id { shift->_identity }
67
68 1;
69