1
0
Fork 0

Merge pull request #3442 from Alkarex/any_value_dbstructure

Fix GROUP BY in dbstructure
This commit is contained in:
Michael Vogel 2017-05-07 12:16:10 +02:00 committed by GitHub
commit 9c3e968581

View file

@ -398,6 +398,14 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$sql3 .= ";";
}
$field_list = '';
if ($is_unique && $ignore == '') {
foreach ($structure['fields'] AS $fieldname => $parameters) {
$field_list .= 'ANY_VALUE(`' . $fieldname . '`),';
}
$field_list = rtrim($field_list, ',');
}
if ($verbose) {
// Ensure index conversion to unique removes duplicates
if ($is_unique) {
@ -414,7 +422,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
if ($ignore != "") {
echo "SET session old_alter_table=0;\n";
} else {
echo "INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";\n";
echo "INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";\n";
echo "DROP TABLE `".$name."`;\n";
echo "RENAME TABLE `".$temp_name."` TO `".$name."`;\n";
}
@ -445,7 +453,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
if ($ignore != "") {
$db->q("SET session old_alter_table=0;");
} else {
$r = $db->q("INSERT INTO `".$temp_name."` SELECT * FROM `".$name."`".$group_by.";");
$r = $db->q("INSERT INTO `".$temp_name."` SELECT ".$field_list." FROM `".$name."`".$group_by.";");
if (!dbm::is_result($r)) {
$errors .= print_update_error($db, $sql3);
return $errors;