From: Rafael Kitover <rkitover@cpan.org> Date: Mon, 20 Jul 2009 17:06:46 +0000 (+0000) Subject: change the (incorrect) version check to a check for FreeTDS X-Git-Tag: v0.08112~14^2~98 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8c4b6c50e873a2b5993d1bfe0f40763d994b7da4;p=dbsrgits%2FDBIx-Class.git change the (incorrect) version check to a check for FreeTDS --- diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index d58114d..9eb7e01 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -31,8 +31,9 @@ without doing a C<select max(col)>. But your queries will be cached. -You need at least version C<1.09> of L<DBD::Sybase> for placeholder support. -Otherwise your storage will be automatically reblessed into C<::NoBindVars>. +You need a version of L<DBD::Sybase> compiled with the Sybase OpenClient +libraries, B<NOT> FreeTDS, for placeholder support. Otherwise your storage will +be automatically reblessed into C<::NoBindVars>. A recommended L<DBIx::Class::Storage::DBI/connect_info> settings: @@ -70,14 +71,16 @@ sub _rebless { $self->_rebless; } - if ($DBD::Sybase::VERSION < 1.09) { + if ($self->_using_freetds) { carp <<'EOF'; Your version of Sybase potentially supports placeholders and query caching, -however your version of DBD::Sybase is too old to do this properly. Please -upgrade to at least version 1.09 if you want this feature. +however you seem to be using FreeTDS which does not (yet?) support this. -TEXT/IMAGE column support will also not work in older versions of DBD::Sybase. +Please recompile DBD::Sybase with the Sybase OpenClient libraries if you want +these features. + +TEXT/IMAGE column support will also not work under FreeTDS. See perldoc DBIx::Class::Storage::DBI::Sybase for more details. EOF @@ -90,6 +93,22 @@ EOF } } +{ + my $using_freetds = undef; + + sub _using_freetds { + my $self = shift; + my $dbh = $self->_dbh; + + return $using_freetds if defined $using_freetds; + + local $dbh->{syb_rowcount} = 1; # this is broken in freetds + $using_freetds = @{ $dbh->selectall_arrayref('sp_help') } != 1; + + return $using_freetds; + } +} + sub _set_maxConnect { my $self = shift; @@ -385,8 +404,8 @@ for L<DBIx::Class::InflateColumn::DateTime>. =head1 IMAGE AND TEXT COLUMNS -You need at least version C<1.09> of L<DBD::Sybase> for C<TEXT/IMAGE> column -support. +L<DBD::Sybase> compiled with FreeTDS will B<NOT> work with C<TEXT/IMAGE> +columns. See L</connect_call_blob_setup> for a L<DBIx::Class::Storage::DBI/connect_info> setting you need to work with C<IMAGE> columns. diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm index 4e62d73..b918682 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/NoBindVars.pm @@ -66,11 +66,18 @@ without placeholder support =head1 DESCRIPTION If you're using this driver than your version of Sybase does not support -placeholders, or your version of L<DBD::Sybase> is too old (you need at least -C<1.09>. You can check with: +placeholders, or your version of L<DBD::Sybase> was compiled with FreeTDS rather +than the Sybase OpenClient libraries. You can check with: $dbh->{syb_dynamic_supported} +To see if you are using FreeTDS, run: + + perl -MDBD::Sybase -le 'print grep /Sybase\./, @DynaLoader::dl_shared_objects' | xargs ldd + +If you see C<libct.so> or similar, rather than C<libsybct.so> then you are using +FreeTDS. + You can also enable this driver explicitly using: my $schema = SchemaClass->clone; diff --git a/t/746sybase.t b/t/746sybase.t index 63e4d76..91bfb24 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -46,7 +46,7 @@ for my $storage_type (@storage_types) { if ($storage_idx == 0 && $schema->storage->isa('DBIx::Class::Storage::DBI::Sybase::NoBindVars')) { -# no placeholders in this version of Sybase or DBD::Sybase +# no placeholders in this version of Sybase or DBD::Sybase (or using FreeTDS) my $tb = Test::More->builder; $tb->skip('no placeholders') for 1..$TESTS; next; @@ -130,8 +130,8 @@ SQL # mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t SKIP: { - skip 'Need at least version 1.09 of DBD::Sybase to test TEXT/IMAGE', 12 - unless $DBD::Sybase::VERSION >= 1.09; + skip 'TEXT/IMAGE support does not work with FreeTDS', 12 + if $schema->storage->_using_freetds; my $dbh = $schema->storage->dbh; {