From 2aecbf41e1e0672cce94a7fc5f07d0cbe8587320 Mon Sep 17 00:00:00 2001 From: Lakshay arora Date: Tue, 27 Mar 2018 10:18:50 +0530 Subject: [PATCH] Fixes error in foreign key sql generation + drop foreign key contraint (#14031) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes error in foreign key sql genration, issue #14030 Changed: templates/table/relation/foreign_key_row.twig The destination_column_names were getting passed as a 1d array, the names when extracted gave a string. Passing it as a 2d array (see templates/table/relation/foreign_key_row.twig lines 123,133) fixes the issue. Sign-Off-By: Lakshay arora (b16060@students.iitmandi.ac.in) * Fixes error in foreign key sql generation + drop foreign key contraint, issue #14030 Changed: templates/table/relation/foreign_key_row.twig Fix #13941 Fix #14009 Close #14037 Close #14010 Signed-off-by: Lakshay arora (cherry picked from commit 00b59624e35cc39fd7bcea68453cc0f98c8dfeac) Signed-off-by: MaurĂ­cio Meneghini Fauth --- templates/table/relation/foreign_key_row.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/table/relation/foreign_key_row.twig b/templates/table/relation/foreign_key_row.twig index c56ce6f0ea..caab9a4251 100644 --- a/templates/table/relation/foreign_key_row.twig +++ b/templates/table/relation/foreign_key_row.twig @@ -4,7 +4,7 @@ {% set js_msg = '' %} {% set this_params = null %} {% if one_key['constraint'] is defined %} - {% set drop_fk_query = 'ALTER TABLE ' ~ Util_backquote(table) + {% set drop_fk_query = 'ALTER TABLE ' ~ Util_backquote(db) ~ '.' ~ Util_backquote(table) ~ ' DROP FOREIGN KEY ' ~ Util_backquote(one_key['constraint']) ~ ';' %} @@ -18,7 +18,7 @@ ) } %} {% set js_msg = Sanitize_jsFormat( - 'ALTER TABLE ' ~ table + 'ALTER TABLE ' ~ db ~ '.' ~ table ~ ' DROP FOREIGN KEY ' ~ one_key['constraint'] ~ ';' ) %} @@ -120,7 +120,7 @@ {% for foreign_column in one_key['ref_index_list'] %} {% include 'table/relation/relational_dropdown.twig' with { - 'name': 'destination_foreign_column[' ~ i ~ ']', + 'name': 'destination_foreign_column[' ~ i ~ '][]', 'title': 'Column'|trans, 'values': unique_columns, 'foreign': foreign_column @@ -130,7 +130,7 @@ {% else %} {% include 'table/relation/relational_dropdown.twig' with { - 'name': 'destination_foreign_column[' ~ i ~ ']', + 'name': 'destination_foreign_column[' ~ i ~ '][]', 'title': 'Column'|trans, 'values': [], 'foreign': ''