move placeholder support detection into ::Sybase::Base
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase / Base.pm
index 4dcea42..b9c1de0 100644 (file)
@@ -1,30 +1,24 @@
-package DBIx::Class::Storage::DBI::Sybase::Base;
+package # hide from PAUSE
+    DBIx::Class::Storage::DBI::Sybase::Base;
 
 use strict;
 use warnings;
 
+use base qw/DBIx::Class::Storage::DBI/;
+use mro 'c3';
+
 =head1 NAME
 
 DBIx::Class::Storage::DBI::Sybase::Base - Common functionality for drivers using
-L<DBD::Sybase>
-
-=head1 METHODS
-
-=head2 connected
-
-Returns true if we have an open (and working) database connection, false if it
-is not (yet) open (or does not work). (Executes a simple SELECT to make sure it
-works.)
-
-The reason this is needed is that L<DBD::Sybase>'s ping() does not work with an
-active statement handle, leading to masked database errors.
+DBD::Sybase
 
 =cut
 
-sub connected {
+sub _ping {
   my $self = shift;
 
-  my $dbh = $self->_dbh;
+  my $dbh = $self->_dbh or return 0;
+
   local $dbh->{RaiseError} = 1;
   eval {
     $dbh->do('select 1');
@@ -33,6 +27,18 @@ sub connected {
   return $@ ? 0 : 1;
 }
 
+sub _placeholders_supported {
+  my $self = shift;
+  my $dbh  = $self->_dbh;
+
+  return eval {
+# There's also $dbh->{syb_dynamic_supported} but it can be inaccurate for this
+# purpose.
+    local $dbh->{PrintError} = 0;
+    $dbh->selectrow_array('select 1 where 1 = ?', {}, 1);
+  };
+}
+
 1;
 
 =head1 AUTHORS