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