[Bast-commits] r7365 - in DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage: . DBI DBI/Sybase

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Aug 23 08:01:11 GMT 2009


Author: ribasushi
Date: 2009-08-23 08:01:10 +0000 (Sun, 23 Aug 2009)
New Revision: 7365

Modified:
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
   DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
Log:
Generalize and hide placeholder support check

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	2009-08-23 08:00:34 UTC (rev 7364)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase/Base.pm	2009-08-23 08:01:10 UTC (rev 7365)
@@ -35,47 +35,6 @@
   return $@ ? 0 : 1;
 }
 
-=head2 placeholders_supported
-
-Whether or not string placeholders work. Does not check for implicit conversion
-errors, see L</placeholders_with_type_conversion_supported>.
-
-=cut
-
-sub placeholders_supported {
-  my $self = shift;
-  my $dbh  = $self->_get_dbh;
-
-  return eval {
-# There's also $dbh->{syb_dynamic_supported} but it can be inaccurate for this
-# purpose.
-    local $dbh->{PrintError} = 0;
-    local $dbh->{RaiseError} = 1;
-    $dbh->selectrow_array('select ?', {}, 1);
-  };
-}
-
-=head2 placeholders_with_type_conversion_supported 
-
-Checks if placeholders bound to non-string types throw implicit type conversion
-errors or not.
-
-See L<DBIx::Class::Storage::DBI::Sybase/connect_call_set_auto_cast>.
-
-=cut
-
-sub placeholders_with_type_conversion_supported {
-  my $self = shift;
-  my $dbh  = $self->_dbh;
-
-  return eval {
-    local $dbh->{PrintError} = 0;
-    local $dbh->{RaiseError} = 1;
-# this specifically tests a bind that is NOT a string
-    $dbh->selectrow_array('select 1 where 1 = ?', {}, 1);
-  };
-}
-
 sub _set_max_connect {
   my $self = shift;
   my $val  = shift || 256;

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-08-23 08:00:34 UTC (rev 7364)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI/Sybase.pm	2009-08-23 08:01:10 UTC (rev 7365)
@@ -83,8 +83,8 @@
 To turn off this warning set the DBIC_SYBASE_FREETDS_NOWARN environment
 variable.
 EOF
-        if (not $self->placeholders_with_type_conversion_supported) {
-          if ($self->placeholders_supported) {
+        if (not $self->_typeless_placeholders_supported) {
+          if ($self->_placeholders_supported) {
             $self->auto_cast(1);
           } else {
             $self->ensure_class_loaded($no_bind_vars);

Modified: DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2009-08-23 08:00:34 UTC (rev 7364)
+++ DBIx-Class/0.08/branches/sybase/lib/DBIx/Class/Storage/DBI.pm	2009-08-23 08:01:10 UTC (rev 7365)
@@ -1900,9 +1900,6 @@
   return @{$_[2]};
 }
 
-
-
-
 sub source_bind_attributes {
   my ($self, $source) = @_;
 
@@ -2076,6 +2073,38 @@
 
 sub sqlt_type { shift->_get_dbh->{Driver}->{Name} }
 
+
+# Check if placeholders are supported at all
+sub _placeholders_supported {
+  my $self = shift;
+  my $dbh  = $self->_get_dbh;
+
+  # some drivers provide a $dbh attribute (e.g. Sybase and $dbh->{syb_dynamic_supported})
+  # but it is inaccurate more often than not
+  eval {
+    local $dbh->{PrintError} = 0;
+    local $dbh->{RaiseError} = 1;
+    $dbh->do('select ?', {}, 1);
+  };
+  return $@ ? 0 : 1;
+}
+
+# Check if placeholders bound to non-string types throw exceptions
+#
+sub _typeless_placeholders_supported {
+  my $self = shift;
+  my $dbh  = $self->_get_dbh;
+
+  eval {
+    local $dbh->{PrintError} = 0;
+    local $dbh->{RaiseError} = 1;
+    # this specifically tests a bind that is NOT a string
+    $dbh->do('select 1 where 1 = ?', {}, 1);
+  };
+  return $@ ? 0 : 1;
+}
+
+
 =head2 bind_attribute_by_data_type
 
 Given a datatype from column info, returns a database specific bind




More information about the Bast-commits mailing list