Merge 'trunk' into 'oracle_quotes'
Peter Rabbitson [Tue, 23 Feb 2010 10:38:55 +0000 (10:38 +0000)]
r8808@Thesaurus (orig r8795):  caelum | 2010-02-22 20:16:07 +0100
with_deferred_fk_checks for Oracle
r8809@Thesaurus (orig r8796):  rabbit | 2010-02-22 21:26:20 +0100
Add a hidden option to dbicadmin to self-inject autogenerated POD
r8810@Thesaurus (orig r8797):  caelum | 2010-02-22 21:48:43 +0100
improve with_deferred_fk_checks for Oracle, add tests
r8812@Thesaurus (orig r8799):  rbuels | 2010-02-22 23:09:40 +0100
added package name to DBD::Pg warning in Pg storage driver to make it explicit where the warning is coming from
r8815@Thesaurus (orig r8802):  rabbit | 2010-02-23 11:21:10 +0100
Looks like the distdir wrapping is finally taken care of

lib/DBIx/Class/Storage/DBI.pm
lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm

index d56cd44..b1b84c7 100644 (file)
@@ -40,6 +40,7 @@ __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks');
 # Each of these methods need _determine_driver called before itself
 # in order to function reliably. This is a purely DRY optimization
 my @rdbms_specific_methods = qw/
+  deployment_statements
   sqlt_type
   build_datetime_parser
   datetime_parser_type
index 448c203..2644d43 100644 (file)
@@ -30,6 +30,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 = ();
@@ -65,6 +81,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{
@@ -74,14 +94,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 . "'.");
 }
@@ -162,7 +185,7 @@ names to uppercase
 sub columns_info_for {
   my ($self, $table) = @_;
 
-  $self->next::method(uc($table));
+  $self->next::method($table);
 }
 
 =head2 datetime_parser_type