Merge branch 'master' into topic/constructor_rewrite
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Sybase / Microsoft_SQL_Server.pm
index f1ea17c..b3f048c 100644 (file)
@@ -44,7 +44,7 @@ sub _rebless {
 
   return if ref $self ne __PACKAGE__;
   if (not $self->_use_typeless_placeholders) {
-    carp <<'EOF' unless $ENV{DBIC_MSSQL_FREETDS_LOWVER_NOWARN};
+    carp_once <<'EOF' unless $ENV{DBIC_MSSQL_FREETDS_LOWVER_NOWARN};
 Placeholders do not seem to be supported in your configuration of
 DBD::Sybase/FreeTDS.
 
@@ -65,6 +65,28 @@ EOF
   }
 }
 
+sub _init {
+  my $self = shift;
+
+  $self->next::method(@_);
+
+  # work around massively broken freetds versions after 0.82
+  # - explicitly no scope_identity
+  # - no sth caching
+  #
+  # warn about the fact as well, do not provide a mechanism to shut it up
+  if ($self->_using_freetds and (my $ver = $self->_using_freetds_version||999) > 0.82) {
+    carp_once(
+      "Your DBD::Sybase was compiled against buggy FreeTDS version $ver. "
+    . 'Statement caching does not work and will be disabled.'
+    );
+
+    $self->_identity_method('@@identity');
+    $self->_no_scope_identity_query(1);
+    $self->disable_sth_caching(1);
+  }
+}
+
 # invoked only if DBD::Sybase is compiled against FreeTDS
 sub _set_autocommit_stmt {
   my ($self, $on) = @_;
@@ -124,7 +146,7 @@ package # hide from PAUSE
   DBIx::Class::Storage::DBI::Sybase::Microsoft_SQL_Server::DateTime::Format;
 
 my $datetime_parse_format  = '%Y-%m-%dT%H:%M:%S.%3NZ';
-my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T 
+my $datetime_format_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T
 
 my ($datetime_parser, $datetime_formatter);