Streamline connection codepath, fix $ENV{DBI_DSN} regression from d87929a4
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
index 901cf0a..79a449e 100644 (file)
@@ -28,7 +28,7 @@ sub _rebless {
   try {
     $dbtype = @{$self->_get_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2]
   } catch {
-    $self->throw_exception("Unable to estable connection to determine database type: $_")
+    $self->throw_exception("Unable to establish connection to determine database type: $_")
   };
 
   if ($dbtype) {
@@ -49,7 +49,7 @@ sub _init {
   # 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)};
@@ -83,8 +83,7 @@ sub _ping {
 
   if ($dbh->{syb_no_child_con}) {
     return try {
-      $self->_connect(@{$self->_dbi_connect_info || [] })
-        ->do('select 1');
+      $self->_connect->do('select 1');
       1;
     }
     catch {
@@ -117,19 +116,21 @@ sub _set_max_connect {
   }
 }
 
-=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