}
}
+# Whether or not we are connecting via the freetds ODBC driver.
+sub _using_freetds {
+ my $self = shift;
+
+ my $dsn = $self->_dbi_connect_info->[0];
+
+ return 1 if (
+ ( (! ref $dsn) and $dsn =~ /driver=FreeTDS/i)
+ or
+ ( ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i )
+ );
+
+ return 0;
+}
+
+# Either returns the FreeTDS version via which we are connecting, 0 if can't
+# be determined, or undef otherwise
+sub _using_freetds_version {
+ my $self = shift;
+ return undef unless $self->_using_freetds;
+ return $self->_dbh_get_info('SQL_DRIVER_VER') || 0;
+}
+
1;
=head1 NAME
use warnings;
use base qw/
- DBIx::Class::Storage::DBI::DB2
DBIx::Class::Storage::DBI::ODBC
+ DBIx::Class::Storage::DBI::DB2
/;
use mro 'c3';
use strict;
use warnings;
-use base 'DBIx::Class::Storage::DBI::Firebird::Common';
+use base qw/
+ DBIx::Class::Storage::DBI::ODBC
+ DBIx::Class::Storage::DBI::Firebird::Common
+/;
use mro 'c3';
use Try::Tiny;
use namespace::clean;
use strict;
use warnings;
-use base qw/DBIx::Class::Storage::DBI::MSSQL/;
+use base qw/
+ DBIx::Class::Storage::DBI::ODBC
+ DBIx::Class::Storage::DBI::MSSQL
+/;
use mro 'c3';
use Scalar::Util 'reftype';
use Try::Tiny;
}
if ($dsn !~ /MARS_Connection=/) {
- if ($self->using_freetds) {
+ if ($self->_using_freetds) {
$self->throw_exception('FreeTDS does not support MARS at the time of '
.'writing.');
}
$self->throw_exception (
'Your drivers do not seem to support dynamic cursors (odbc_cursortype => 2).'
. (
- $self->using_freetds
+ $self->_using_freetds
? ' If you are using FreeTDS, make sure to set tds_version to 8.0 or greater.'
: ''
)
$self->_using_dynamic_cursors(1);
$self->_identity_method('@@identity');
- $self->_no_scope_identity_query($self->using_freetds);
+ $self->_no_scope_identity_query($self->_using_freetds);
}
else {
$self->_using_dynamic_cursors(0);
$self->next::method (@_);
# freetds is too damn broken, some fixups
- if ($self->using_freetds) {
+ if ($self->_using_freetds) {
# no dynamic cursors starting from 0.83
if ($self->_using_dynamic_cursors) {
- my $fv = $self->_dbh_get_info('SQL_DRIVER_VER');
+ my $fv = $self->_using_freetds_version || 999; # assume large if can't be determined
$self->throw_exception(
'Dynamic cursors (odbc_cursortype => 2) are not supported with FreeTDS > 0.82 '
. "(you have $fv). Please hassle FreeTDS authors to fix the outstanding bugs in "
$self->_get_dbh->{odbc_SQL_ROWSET_SIZE} = $sql_rowset_size;
}
-=head2 using_freetds
-
-Tries to determine, to the best of our ability, whether or not you are using the
-FreeTDS driver with L<DBD::ODBC>.
-
-=cut
-
-sub using_freetds {
- my $self = shift;
-
- my $dsn = $self->_dbi_connect_info->[0];
-
- $dsn = '' if ref $dsn eq 'CODE';
-
- return 1 if $dsn =~ /driver=FreeTDS/i
- || ($self->_dbh_get_info('SQL_DRIVER_NAME')||'') =~ /tdsodbc/i;
-
- return 0;
-}
-
1;
=head1 AUTHOR
use strict;
use warnings;
-use base qw/DBIx::Class::Storage::DBI::SQLAnywhere/;
+use base qw/
+ DBIx::Class::Storage::DBI::ODBC
+ DBIx::Class::Storage::DBI::SQLAnywhere
+/;
use mro 'c3';
1;
# once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups
# this is a dirty version of "instance role application", \o/ DO WANT Moo \o/
my $self = shift;
- if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->using_freetds) {
+ if (! $self->isa('DBIx::Class::Storage::DBI::Sybase::FreeTDS') and $self->_using_freetds) {
require DBIx::Class::Storage::DBI::Sybase::FreeTDS;
my @isa = @{mro::get_linear_isa(ref $self)};
}
}
-=head2 using_freetds
-
-Whether or not L<DBD::Sybase> was compiled against FreeTDS. If false, it means
-the Sybase OpenClient libraries were used.
-
-=cut
-
-sub using_freetds {
+# Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means
+# the Sybase OpenClient libraries were used.
+sub _using_freetds {
my $self = shift;
-
return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i;
}
+# Either returns the FreeTDS version against which DBD::Sybase was compiled,
+# 0 if can't be determined, or undef otherwise
+sub _using_freetds_version {
+ my $inf = shift->_get_dbh->{syb_oc_version};
+ return undef unless ($inf||'') =~ /freetds/i;
+ return $inf =~ /v([0-9\.]+)/ ? $1 : 0;
+}
+
1;
=head1 AUTHORS
my $no_bind_vars = __PACKAGE__ . '::NoBindVars';
- if ($self->using_freetds) {
+ if ($self->_using_freetds) {
carp_once <<'EOF' unless $ENV{DBIC_SYBASE_FREETDS_NOWARN};
You are using FreeTDS with Sybase.
}
$self->_dbh->{syb_chained_txn} = 1
- unless $self->using_freetds;
+ unless $self->_using_freetds;
$self->next::method(@_);
}
$sth->func('ct_finish_send') or die $sth->errstr;
}
catch {
- if ($self->using_freetds) {
+ if ($self->_using_freetds) {
$self->throw_exception (
"TEXT/IMAGE operation failed, probably because you are using FreeTDS: $_"
);
Sybase ASE for Linux (which comes with the Open Client libraries) may be
downloaded here: L<http://response.sybase.com/forms/ASE_Linux_Download>.
-To see if you're using FreeTDS check C<< $schema->storage->using_freetds >>, or run:
+To see if you're using FreeTDS run:
perl -MDBI -le 'my $dbh = DBI->connect($dsn, $user, $pass); print $dbh->{syb_oc_version}'
{ opts => { on_connect_call => 'use_mars' } },
use_dynamic_cursors =>
{ opts => { on_connect_call => 'use_dynamic_cursors' },
- required => $schema->storage->using_freetds ? 0 : 1,
+ required => $schema->storage->_using_freetds ? 0 : 1,
},
use_server_cursors =>
{ opts => { on_connect_call => 'use_server_cursors' } },
TODO: {
my $freetds_and_dynamic_cursors = 1
if $opts_name eq 'use_dynamic_cursors' &&
- $schema->storage->using_freetds;
+ $schema->storage->_using_freetds;
local $TODO =
'these tests fail on freetds with dynamic cursors for some reason'
# mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t
SKIP: {
skip 'TEXT/IMAGE support does not work with FreeTDS', 22
- if $schema->storage->using_freetds;
+ if $schema->storage->_using_freetds;
my $dbh = $schema->storage->_dbh;
{
my $maxloblen = length $binstr{'large'};
- if (not $schema->storage->using_freetds) {
+ if (not $schema->storage->_using_freetds) {
$dbh->{'LongReadLen'} = $maxloblen * 2;
} else {
$dbh->do("set textsize ".($maxloblen * 2));