From 98a7479174a081ac60419034151fd89ec952265f Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Mon, 19 Aug 2019 18:00:18 +0200 Subject: [PATCH] Fix NULL wrongly checked on field change When a field was requested to be changed, the "null" field was compared to its previous value. Unfortunately, both fields don't have the same value, so a change was always identified. Signed-off-by: Hugues Peccatte --- .../classes/Controllers/Table/TableStructureController.php | 4 ++-- libraries/classes/Table.php | 4 ++-- templates/columns_definitions/column_null.twig | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/classes/Controllers/Table/TableStructureController.php b/libraries/classes/Controllers/Table/TableStructureController.php index 8e38edc525..de5b85bf58 100644 --- a/libraries/classes/Controllers/Table/TableStructureController.php +++ b/libraries/classes/Controllers/Table/TableStructureController.php @@ -883,7 +883,7 @@ class TableStructureController extends TableController $_POST['field_length'][$i], $_POST['field_attribute'][$i], Util::getValueByKey($_POST, "field_collation.${i}", ''), - Util::getValueByKey($_POST, "field_null.${i}", 'NOT NULL'), + Util::getValueByKey($_POST, "field_null.${i}", 'NO'), $_POST['field_default_type'][$i], $_POST['field_default_value'][$i], Util::getValueByKey($_POST, "field_extra.${i}", false), @@ -1030,7 +1030,7 @@ class TableStructureController extends TableController $_POST['field_length_orig'][$i], $_POST['field_attribute_orig'][$i], Util::getValueByKey($_POST, "field_collation_orig.${i}", ''), - Util::getValueByKey($_POST, "field_null_orig.${i}", 'NOT NULL'), + Util::getValueByKey($_POST, "field_null_orig.${i}", 'NO'), $_POST['field_default_type_orig'][$i], $_POST['field_default_value_orig'][$i], Util::getValueByKey($_POST, "field_extra_orig.${i}", false), diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index d137109b95..b9f7233ffd 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -534,7 +534,7 @@ class Table if (! $virtuality || $isVirtualColMysql) { if ($null !== false) { - if ($null == 'NULL') { + if ($null == 'YES') { $query .= ' NULL'; } else { $query .= ' NOT NULL'; @@ -573,7 +573,7 @@ class Table case 'NULL' : // If user uncheck null checkbox and not change default value null, // default value will be ignored. - if ($null !== false && $null !== 'NULL') { + if ($null !== false && $null !== 'YES') { break; } // else fall-through intended, no break here diff --git a/templates/columns_definitions/column_null.twig b/templates/columns_definitions/column_null.twig index 03b71e129c..faedd60baf 100644 --- a/templates/columns_definitions/column_null.twig +++ b/templates/columns_definitions/column_null.twig @@ -4,5 +4,5 @@ checked="checked" {%- endif %} type="checkbox" - value="NULL" + value="YES" class="allow_null" />