DBIx-Class
view release on metacpan or search on metacpan
lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm view on Meta::CPAN
$sth->finish if $sth;
};
}
}
sub _insert_blobs_array {
my ($self, $source, $blob_cols, $cols, $data) = @_;
for my $i (0..$#$data) {
my $datum = $data->[$i];
my %row;
@row{ @$cols } = @$datum;
my %blob_vals;
for my $j (0..$#$cols) {
if (exists $blob_cols->[$i][$j]) {
$blob_vals{ $cols->[$j] } = $blob_cols->[$i][$j];
}
}
$self->_insert_blobs ($source, \%blob_vals, \%row);
}
}
=head2 connect_call_datetime_setup
Used as:
on_connect_call => 'datetime_setup'
In L<connect_info|DBIx::Class::Storage::DBI/connect_info> to set:
$dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z
$dbh->do('set dateformat mdy'); # input fmt: 08/13/1979 18:08:55.080
This works for both C<DATETIME> and C<SMALLDATETIME> columns, note that
C<SMALLDATETIME> columns only have minute precision.
=cut
sub connect_call_datetime_setup {
my $self = shift;
my $dbh = $self->_get_dbh;
if ($dbh->can('syb_date_fmt')) {
# amazingly, this works with FreeTDS
$dbh->syb_date_fmt('ISO_strict');
}
else {
carp_once
'Your DBD::Sybase is too old to support '
.'DBIx::Class::InflateColumn::DateTime, please upgrade!';
# FIXME - in retrospect this is a rather bad US-centric choice
# of format. Not changing as a bugwards compat, though in reality
# the only piece that sees the results of $dt object formatting
# (as opposed to parsing) is the database itself, so theoretically
# changing both this SET command and the formatter definition of
# ::S::D::Sybase::ASE::DateTime::Format below should be safe and
# transparent
$dbh->do('SET DATEFORMAT mdy');
}
}
sub _exec_txn_begin {
my $self = shift;
# bulkLogin=1 connections are always in a transaction, and can only call BEGIN
# TRAN once. However, we need to make sure there's a $dbh.
return if $self->_is_bulk_storage && $self->_dbh && $self->_began_bulk_work;
$self->next::method(@_);
$self->_began_bulk_work(1) if $self->_is_bulk_storage;
}
# savepoint support using ASE syntax
sub _exec_svp_begin {
my ($self, $name) = @_;
$self->_dbh->do("SAVE TRANSACTION $name");
}
# A new SAVE TRANSACTION with the same name releases the previous one.
sub _exec_svp_release { 1 }
sub _exec_svp_rollback {
my ($self, $name) = @_;
$self->_dbh->do("ROLLBACK TRANSACTION $name");
}
package # hide from PAUSE
DBIx::Class::Storage::DBI::Sybase::ASE::DateTime::Format;
my $datetime_parse_format = '%Y-%m-%dT%H:%M:%S.%3NZ';
my $datetime_format_format = '%m/%d/%Y %H:%M:%S.%3N';
my ($datetime_parser, $datetime_formatter);
sub parse_datetime {
shift;
require DateTime::Format::Strptime;
$datetime_parser ||= DateTime::Format::Strptime->new(
pattern => $datetime_parse_format,
on_error => 'croak',
);
return $datetime_parser->parse_datetime(shift);
}
sub format_datetime {
shift;
require DateTime::Format::Strptime;
$datetime_formatter ||= DateTime::Format::Strptime->new(
pattern => $datetime_format_format,
on_error => 'croak',
);
( run in 1.551 second using v1.01-cache-2.11-cpan-39bf76dae61 )