use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
+use DBIx::Class::_Util 'modver_gt_or_eq';
+use namespace::clean;
+
sub _rebless { shift->_determine_connector_driver('ODBC') }
# Whether or not we are connecting via the freetds ODBC driver
my $self = shift;
my $dbh = $self->_get_dbh;
- if (eval { DBD::ODBC->VERSION(1.35_01) }) {
- $dbh->{odbc_array_operations} = 0;
- }
- elsif (eval { DBD::ODBC->VERSION(1.33_01) }) {
- $dbh->{odbc_disable_array_operations} = 1;
+ $DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__ ||= [ do {
+ if( modver_gt_or_eq('DBD::ODBC', '1.35_01') ) {
+ odbc_array_operations => 0;
+ }
+ elsif( modver_gt_or_eq('DBD::ODBC', '1.33_01') ) {
+ odbc_disable_array_operations => 1;
+ }
+ }];
+
+ if (my ($k, $v) = @$DBD::ODBC::__DBIC_DISABLE_ARRAY_OPS_VIA__) {
+ $dbh->{$k} = $v;
}
}
use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
+use DBIx::Class::_Util 'modver_gt_or_eq';
use DBIx::Class::Carp;
use Try::Tiny;
use namespace::clean;
# older DBD::SQLite does not properly synchronize commit state between
# the libsqlite and the $dbh
unless (defined $DBD::SQLite::__DBIC_TXN_SYNC_SANE__) {
- local $@;
- $DBD::SQLite::__DBIC_TXN_SYNC_SANE__ = eval { DBD::SQLite->VERSION(1.38_02); 1 }
- ? 1
- : 0
- ;
+ $DBD::SQLite::__DBIC_TXN_SYNC_SANE__ = modver_gt_or_eq('DBD::SQLite', '1.38_02');
}
# fallback to travesty
--- /dev/null
+package # hide from PAUSE
+ DBIx::Class::_Util;
+
+use warnings;
+use strict;
+
+use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0);
+
+use Carp;
+
+use base 'Exporter';
+our @EXPORT_OK = qw(modver_gt_or_eq);
+
+sub modver_gt_or_eq {
+ my ($mod, $ver) = @_;
+
+ croak "Nonsensical module name supplied"
+ if ! defined $mod or ! length $mod;
+
+ croak "Nonsensical minimum version supplied"
+ if ! defined $ver or $ver =~ /[^0-9\.\_]/;
+
+ local $SIG{__WARN__} = do {
+ my $orig_sig_warn = $SIG{__WARN__} || sub { warn @_ };
+ sub {
+ $orig_sig_warn->(@_) unless $_[0] =~ /\Qisn't numeric in subroutine entry/
+ }
+ } if SPURIOUS_VERSION_CHECK_WARNINGS;
+
+ local $@;
+ eval { $mod->VERSION($ver) } ? 1 : 0;
+}
+
+1;
DBIx::Class::Storage::DBIHacks
DBIx::Class::Storage::BlockRunner
DBIx::Class::Carp
+ DBIx::Class::_Util
DBIx::Class::ResultSet::Pager
/);
# from the parent
'DBIx::Class::ResultSet::Pager',
- # a utility class, not part of the inheritance chain
+ # utility classes, not part of the inheritance chain
'DBIx::Class::ResultSource::RowParser::Util',
+ 'DBIx::Class::_Util',
) };
my $has_cmop = eval { require Class::MOP };
use lib qw(t/lib);
use DBICTest;
+use DBIx::Class::_Util 'modver_gt_or_eq';
# savepoints test
{
# However DBD::SQLite 1.38_02 seems to fix this, with an accompanying test:
# https://metacpan.org/source/ADAMK/DBD-SQLite-1.38_02/t/54_literal_txn.t
-my $lit_txn_todo = eval { DBD::SQLite->VERSION(1.38_02) }
+my $lit_txn_todo = modver_gt_or_eq('DBD::SQLite', '1.38_02')
? undef
: "DBD::SQLite before 1.38_02 is retarded wrt detecting literal BEGIN/COMMIT statements"
;
# range is -(2**63) .. 2**63 - 1
SKIP: {
skip 'This perl does not seem to have 64bit int support - DBI roundtrip of large int will fail with DBD::SQLite < 1.37', 1
- if ($Config{ivsize} < 8 and ! eval { DBD::SQLite->VERSION(1.37); 1 });
+ if ($Config{ivsize} < 8 and ! modver_gt_or_eq('DBD::SQLite', '1.37') );
for my $bi (qw/
-9223372036854775808
'DBIx::Class::SQLMaker::LimitDialects' => {},
# internals
+ 'DBIx::Class::_Util' => { skip => 1 },
'DBIx::Class::SQLMaker*' => { skip => 1 },
'DBIx::Class::SQLAHacks*' => { skip => 1 },
'DBIx::Class::Storage::DBI*' => { skip => 1 },