still need to uc source_name if quotes off
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Oracle / Generic.pm
index 55cad0e..854566a 100644 (file)
@@ -28,6 +28,22 @@ versions before 9.
 use base qw/DBIx::Class::Storage::DBI/;
 use mro 'c3';
 
+sub deployment_statements {
+  my $self = shift;;
+  my ($schema, $type, $version, $dir, $sqltargs, @rest) = @_;
+
+  $sqltargs ||= {};
+  my $quote_char = $self->schema->storage->{'_sql_maker_opts'}->{'quote_char'};
+  $sqltargs->{quote_table_names} = 0 unless $quote_char;
+  $sqltargs->{quote_field_names} = 0 unless $quote_char;
+
+  my $oracle_version = eval { $self->_get_dbh->get_info(18) };
+
+  $sqltargs->{producer_args}{oracle_version} = $oracle_version;
+
+  $self->next::method($schema, $type, $version, $dir, $sqltargs, @rest);
+}
+
 sub _dbh_last_insert_id {
   my ($self, $dbh, $source, @columns) = @_;
   my @ids = ();
@@ -63,6 +79,10 @@ sub _dbh_get_autoinc_seq {
       $source_name = ${$source->name};
   }
 
+  unless ($self->schema->storage->{'_sql_maker_opts'}->{'quote_char'}) {
+    $source_name =  uc($source_name);
+  }
+
   # check for fully-qualified name (eg. SCHEMA.TABLENAME)
   if ( my ( $schema, $table ) = $source_name =~ /(\w+)\.(\w+)/ ) {
     $sql = q{
@@ -72,14 +92,17 @@ sub _dbh_get_autoinc_seq {
       AND t.status = 'ENABLED'
     };
     $sth = $dbh->prepare($sql);
-    $sth->execute( uc($schema), uc($table) );
+       my $table_name  = $self -> sql_maker -> _quote($table);
+       my $schema_name = $self -> sql_maker -> _quote($schema);
+
+    $sth->execute( $schema_name, $table_name );
   }
   else {
     $sth = $dbh->prepare($sql);
-    $sth->execute( uc( $source_name ) );
+    $sth->execute( $source_name );
   }
   while (my ($insert_trigger) = $sth->fetchrow_array) {
-    return uc($1) if $insert_trigger =~ m!(\w+)\.nextval!i; # col name goes here???
+    return $1 if $insert_trigger =~ m!("?\w+"?)\.nextval!i; # col name goes here???
   }
   $self->throw_exception("Unable to find a sequence INSERT trigger on table '" . $source->name . "'.");
 }
@@ -160,7 +183,7 @@ names to uppercase
 sub columns_info_for {
   my ($self, $table) = @_;
 
-  $self->next::method(uc($table));
+  $self->next::method($table);
 }
 
 =head2 datetime_parser_type
@@ -252,6 +275,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()