summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB
diff options
context:
space:
mode:
authorjustdave%bugzilla.org <>2007-04-15 08:35:56 +0200
committerjustdave%bugzilla.org <>2007-04-15 08:35:56 +0200
commit8da7f321aabe95470944bc23aeed9a06ef6793a5 (patch)
treeb16ca05abfae22dffd3ca8f0c868cc799273f2e7 /Bugzilla/DB
parentb3630da125fa112e04f6e6a15328f64e13a874c5 (diff)
downloadbugzilla-8da7f321aabe95470944bc23aeed9a06ef6793a5.tar.gz
bugzilla-8da7f321aabe95470944bc23aeed9a06ef6793a5.tar.xz
Bug 373869: Custom field names must be all lowercase or buglist.cgi sorting throws an error
Patch by mkanat and justdave r=LpSolit,mkanat; a=mkanat
Diffstat (limited to 'Bugzilla/DB')
-rw-r--r--Bugzilla/DB/Schema.pm48
-rw-r--r--Bugzilla/DB/Schema/Pg.pm15
2 files changed, 63 insertions, 0 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 15d7dd8b2..44bda1acb 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -1911,6 +1911,37 @@ sub get_rename_column_ddl {
. " has not implemented a method.";
}
+
+sub get_rename_table_sql {
+
+=item C<get_rename_table_sql>
+
+=over
+
+=item B<Description>
+
+Gets SQL to rename a table in the database.
+
+=item B<Params>
+
+=over
+
+=item C<$old_name> - The current name of the table.
+
+=item C<$new_name> - The new name of the table.
+
+=back
+
+=item B<Returns>: An array of SQL statements to rename a table.
+
+=back
+
+=cut
+
+ my ($self, $old_name, $new_name) = @_;
+ return ("ALTER TABLE $old_name RENAME TO $new_name");
+}
+
=item C<delete_table($name)>
Description: Deletes a table from this Schema object.
@@ -2062,6 +2093,23 @@ sub add_table {
}
}
+
+
+sub rename_table {
+
+=item C<rename_table>
+
+Renames a table from C<$old_name> to C<$new_name> in this Schema object.
+
+=cut
+
+
+ my ($self, $old_name, $new_name) = @_;
+ my $table = $self->get_table_abstract($old_name);
+ $self->delete_table($old_name);
+ $self->add_table($new_name, $table);
+}
+
sub delete_column {
=item C<delete_column($table, $column)>
diff --git a/Bugzilla/DB/Schema/Pg.pm b/Bugzilla/DB/Schema/Pg.pm
index 0101a1e43..7a951e2db 100644
--- a/Bugzilla/DB/Schema/Pg.pm
+++ b/Bugzilla/DB/Schema/Pg.pm
@@ -92,6 +92,11 @@ sub _initialize {
sub get_rename_column_ddl {
my ($self, $table, $old_name, $new_name) = @_;
+ if (lc($old_name) eq lc($new_name)) {
+ # if the only change is a case change, return an empty list, since Pg
+ # is case-insensitive and will return an error about a duplicate name
+ return ();
+ }
my @sql = ("ALTER TABLE $table RENAME COLUMN $old_name TO $new_name");
my $def = $self->get_column_abstract($table, $old_name);
if ($def->{TYPE} =~ /SERIAL/i) {
@@ -104,6 +109,16 @@ sub get_rename_column_ddl {
return @sql;
}
+sub get_rename_table_sql {
+ my ($self, $old_name, $new_name) = @_;
+ if (lc($old_name) eq lc($new_name)) {
+ # if the only change is a case change, return an empty list, since Pg
+ # is case-insensitive and will return an error about a duplicate name
+ return ();
+ }
+ return ("ALTER TABLE $old_name RENAME TO $new_name");
+}
+
sub _get_alter_type_sql {
my ($self, $table, $column, $new_def, $old_def) = @_;
my @statements;