Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 87815
Status: new
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: BRAD [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.11016
Fixed in: (no value)



Subject: Patch - SQL::Translator::Producer::Oracle cant drop_table at SQL/Translator/Diff.pm line 292.
Hi, having problems with DBIx::Class::DeploymentHandler - SQL::Translator::Diff bombs out when generating Oracle upgrade/downgrade scripts with the error in the title. There isn't a drop_table method in SQL::Translator::Producer::Oracle, so I hacked the following from SQL::Translator::Producer::MySQL: 492 sub quote_table_name { 493 my ($table_name, $qt) = @_; 494 495 $table_name =~ s/\./$qt.$qt/g; 496 497 return "$qt$table_name$qt"; 498 } 499 500 sub drop_table { 501 my ($table, $options) = @_; 502 503 my $qt = $options->{quote_table_names} || ''; 504 505 my $table_name = quote_table_name($table, $qt); 506 return (qq[DROP TABLE $table_name CASCADE CONSTRAINTS]); 507 } I'm happy to submit a proper patch for this (and the missing drop_field method) later on if needed.
On Tue Aug 13 08:48:52 2013, BRAD wrote: Show quoted text
> Hi, having problems with DBIx::Class::DeploymentHandler - > SQL::Translator::Diff bombs out when generating Oracle > upgrade/downgrade scripts with the error in the title. There isn't a > drop_table method in SQL::Translator::Producer::Oracle, so I hacked > the following from SQL::Translator::Producer::MySQL: > > 492 sub quote_table_name { > 493 my ($table_name, $qt) = @_; > 494 > 495 $table_name =~ s/\./$qt.$qt/g; > 496 > 497 return "$qt$table_name$qt"; > 498 } > 499 > 500 sub drop_table { > 501 my ($table, $options) = @_; > 502 > 503 my $qt = $options->{quote_table_names} || ''; > 504 > 505 my $table_name = quote_table_name($table, $qt); > 506 return (qq[DROP TABLE $table_name CASCADE CONSTRAINTS]); > 507 } > > I'm happy to submit a proper patch for this (and the missing > drop_field method) later on if needed.
Patch to add the three methods: --- /home/a530093/perl5/lib/perl5/SQL/Translator/Producer/Oracle.pm.orig 2013-08-21 16:03:55.910188883 +0100 +++ /home/a530093/perl5/lib/perl5/SQL/Translator/Producer/Oracle.pm 2013-08-21 16:07:04.199195125 +0100 @@ -489,6 +489,37 @@ return \@create, \@fk_defs, \@trigger_defs, \@index_defs, ($options->{delay_constraints} ? \@constraint_defs : []); } +sub quote_table_name { + my ($table_name, $qt) = @_; + + $table_name =~ s/\./$qt.$qt/g; + + return "$qt$table_name$qt"; +} + +sub drop_table { + my ($table, $options) = @_; + my $qt = $options->{quote_table_names} || ''; + my $table_name = quote_table_name($table, $qt); + return (qq[DROP TABLE $table_name CASCADE CONSTRAINTS]); +} + +sub drop_field +{ + my ($old_field, $options) = @_; + + my $qf = $options->{quote_field_names} || ''; + my $qt = $options->{quote_table_names} || ''; + my $table_name = quote_table_name($old_field->table->name, $qt); + + my $out = sprintf('ALTER TABLE %s DROP COLUMN %s', + $table_name, + $qf . $old_field->name . $qf); + + return $out; + +} + sub alter_field { my ($from_field, $to_field, $options) = @_; Tested on a fairly small codebase, the generated schema alterations look OK however I've not had a chance to test them in Oracle. Cheers Brad