with_deferred_fk_checks for Oracle
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Oracle / Generic.pm
index 55cad0e..5973319 100644 (file)
@@ -252,6 +252,13 @@ sub source_bind_attributes
     my %column_bind_attrs = $self->bind_attribute_by_data_type($data_type);
 
     if ($data_type =~ /^[BC]LOB$/i) {
+      if ($DBD::Oracle::VERSION eq '1.23') {
+        $self->throw_exception(
+"BLOB/CLOB support in DBD::Oracle == 1.23 is broken, use an earlier or later ".
+"version.\n\nSee: https://rt.cpan.org/Public/Bug/Display.html?id=46016\n"
+        );
+      }
+
       $column_bind_attrs{'ora_type'} = uc($data_type) eq 'CLOB'
         ? DBD::Oracle::ORA_CLOB()
         : DBD::Oracle::ORA_BLOB()
@@ -319,6 +326,25 @@ sub relname_to_table_alias {
   return $new_alias;
 }
 
+=head2 with_deferred_fk_checks
+
+Runs a coderef between:
+
+  alter session set constraints = deferred
+  ...
+  alter session set constraints = immediate
+
+to defer FK checks.
+
+=cut
+
+sub with_deferred_fk_checks {
+  my ($self, $sub) = @_;
+  $self->_do_query('alter session set constraints = deferred');
+  $sub->();
+  $self->_do_query('alter session set constraints = immediate');
+}
+
 =head1 AUTHOR
 
 See L<DBIx::Class/CONTRIBUTORS>.