Firebird: fix test cleanup, add ODBC wrapper
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / InterBase.pm
CommitLineData
88a8d0fa 1package DBIx::Class::Storage::DBI::InterBase;
2
3# mostly stolen from DBIx::Class::Storage::DBI::MSSQL
4
5use strict;
6use warnings;
7
637d2fae 8use base qw/DBIx::Class::Storage::DBI/;
88a8d0fa 9use mro 'c3';
10
11use List::Util();
12
13__PACKAGE__->mk_group_accessors(simple => qw/
4f638386 14 _identity
88a8d0fa 15/);
16
88a8d0fa 17sub 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
32sub _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
46sub _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
66sub last_insert_id { shift->_identity }
67
681;
69