From 3cea91884b28b52df4e38f2ba88c00b65071a81f Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Sat, 25 Oct 2008 04:11:30 +0000 Subject: Bug 291433: Ability to have custom fields whose visibility depends on the values of other fields Patch By Max Kanat-Alexander r=bbaetz, a=mkanat --- Bugzilla/DB.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'Bugzilla/DB.pm') diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index e264dc443..cc4ddb9aa 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -1209,12 +1209,16 @@ sub _check_references { my $foreign_table = $fk->{TABLE}; my $foreign_column = $fk->{COLUMN}; + # We use table aliases because sometimes we join a table to itself, + # and we can't use the same table name on both sides of the join. + # We also can't use the words "table" or "foreign" because those are + # reserved words. my $bad_values = $self->selectcol_arrayref( - "SELECT DISTINCT $table.$column - FROM $table LEFT JOIN $foreign_table - ON $table.$column = $foreign_table.$foreign_column - WHERE $foreign_table.$foreign_column IS NULL - AND $table.$column IS NOT NULL"); + "SELECT DISTINCT tabl.$column + FROM $table AS tabl LEFT JOIN $foreign_table AS forn + ON tabl.$column = forn.$foreign_column + WHERE forn.$foreign_column IS NULL + AND tabl.$column IS NOT NULL"); if (@$bad_values) { my $delete_action = $fk->{DELETE} || ''; -- cgit v1.2.3-24-g4f1b