1 package DBIx::Class::Storage::DBI::InterBase;
3 # partly stolen from DBIx::Class::Storage::DBI::MSSQL
7 use base qw/DBIx::Class::Storage::DBI/;
11 __PACKAGE__->mk_group_accessors(simple => qw/
15 sub _prep_for_execute {
17 my ($op, $extra_bind, $ident, $args) = @_;
19 my ($sql, $bind) = $self->next::method (@_);
21 if ($op eq 'insert') {
22 my @pk = $ident->primary_columns;
26 my @auto_inc_cols = grep {
27 my $inserting = $args->[0]{$_};
29 ($ident->column_info($_)->{is_auto_increment}
32 (not defined $inserting)
34 (ref $inserting eq 'SCALAR' && $$inserting =~ /^null\z/i)
41 map $self->_quote_column_for_returning($_), @auto_inc_cols;
43 $sql .= " RETURNING ($auto_inc_cols)";
45 $self->_auto_incs([]);
46 $self->_auto_incs->[0] = \@auto_inc_cols;
53 sub _quote_column_for_returning {
54 my ($self, $col) = @_;
56 return $self->sql_maker->_quote($col);
63 my ($rv, $sth, @bind) = $self->dbh_do($self->can('_dbh_execute'), @_);
65 if ($op eq 'insert' && $self->_auto_incs) {
67 my (@auto_incs) = eval {
68 local $SIG{__WARN__} = sub {};
71 $self->_auto_incs->[1] = \@auto_incs;
75 return wantarray ? ($rv, $sth, @bind) : $rv;
79 my ($self, $source, @cols) = @_;
83 @auto_incs{ @{ $self->_auto_incs->[0] } } =
84 @{ $self->_auto_incs->[1] };
86 push @result, $auto_incs{$_} for @cols;
91 # this sub stolen from DB2
94 my ( $self, $opts ) = @_;
97 $self->{_sql_maker_opts} = { %$opts };
100 return { limit_dialect => 'FirstSkip', %{$self->{_sql_maker_opts}||{}} };
103 sub datetime_parser_type { __PACKAGE__ }
105 my ($datetime_parser, $datetime_formatter);
109 require DateTime::Format::Strptime;
110 $datetime_parser ||= DateTime::Format::Strptime->new(
111 pattern => '%a %d %b %Y %r',
112 # there should be a %Z (TZ) on the end, but it's ambiguous and not parsed
115 $datetime_parser->parse_datetime(shift);
118 sub format_datetime {
120 require DateTime::Format::Strptime;
121 $datetime_formatter ||= DateTime::Format::Strptime->new(
122 pattern => '%F %H:%M:%S.%4N',
125 $datetime_formatter->format_datetime(shift);