::DBI::Replicated - don't build pool/balancer from connect_info unless necessary
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase.pm
index 0a26173..f1a8dc8 100644 (file)
@@ -5,24 +5,18 @@ use warnings;
 
 use base qw/DBIx::Class::Storage::DBI::NoBindVars/;
 
-my $noquote = {
-    int => qr/^ \-? \d+ $/x,
-    integer => qr/^ \-? \d+ $/x,
-
-    # TODO maybe need to add float/real/etc
-};
-
-sub should_quote_data_type {
-  my $self = shift;
-  my ($type, $value) = @_;
-
-  return $self->next::method(@_) if not defined $value;
-
-  if (my $re = $noquote->{$type}) {
-    return 0 if $value =~ $re;
-  }
-
-  return $self->next::method(@_);
+sub _rebless {
+    my $self = shift;
+
+    my $dbtype = eval { @{$self->_dbh->selectrow_arrayref(qq{sp_server_info \@attribute_id=1})}[2] };
+    unless ( $@ ) {
+        $dbtype =~ s/\W/_/gi;
+        my $subclass = "DBIx::Class::Storage::DBI::Sybase::${dbtype}";
+        if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
+            bless $self, $subclass;
+            $self->_rebless;
+        }
+    }
 }
 
 1;
@@ -37,10 +31,21 @@ This subclass supports L<DBD::Sybase> for real Sybase databases.  If
 you are using an MSSQL database via L<DBD::Sybase>, see
 L<DBIx::Class::Storage::DBI::Sybase::MSSQL>.
 
+=head1 CAVEATS
+
+This storage driver uses L<DBIx::Class::Storage::DBI::NoBindVars> as a base.
+This means that bind variables will be interpolated (properly quoted of course)
+into the SQL query itself, without using bind placeholders.
+
+More importantly this means that caching of prepared statements is explicitly
+disabled, as the interpolation renders it useless.
+
 =head1 AUTHORS
 
 Brandon L Black <blblack@gmail.com>
 
+Justin Hunter <justin.d.hunter@gmail.com>
+
 =head1 LICENSE
 
 You may distribute this code under the same terms as Perl itself.