Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AUTO_INCREMENT error when only exporting table structure in database-level exports; issue #14066 #14119

Merged
merged 2 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions js/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ function setup_table_structure_or_data () {

check_selected_tables();
check_table_select_all();
check_table_select_struture_or_data();
}
}

Expand Down Expand Up @@ -473,6 +474,30 @@ function check_table_select_all () {
}
}

function check_table_select_struture_or_data () {
var str_checked = $('input[name="table_structure[]"]:checked').length;
var data_checked = $('input[name="table_data[]"]:checked').length;
var auto_increment = $('#checkbox_sql_auto_increment');

var pluginName = $('select#plugins').val();
var dataDiv = '#' + pluginName + '_data';
var structureDiv = '#' + pluginName + '_structure';

if (str_checked === 0) {
$(structureDiv).slideUp('slow');
} else {
$(structureDiv).slideDown('slow');
}

if (data_checked === 0) {
$(dataDiv).slideUp('slow');
auto_increment.prop('disabled', true).parent().fadeTo('fast', 0.4);
} else {
$(dataDiv).slideDown('slow');
auto_increment.prop('disabled', false).parent().fadeTo('fast', 1);
}
}

function toggle_table_select_all_str () {
var str_all = $('#table_structure_all').is(':checked');
if (str_all) {
Expand Down Expand Up @@ -581,30 +606,35 @@ AJAX.registerOnload('export.js', function () {
toggle_table_select($(this).closest('tr'));
check_table_select_all();
handleAddProcCheckbox();
check_table_select_struture_or_data();
});

$('input[name="table_structure[]"]').on('change', function () {
check_table_selected($(this).closest('tr'));
check_table_select_all();
handleAddProcCheckbox();
check_table_select_struture_or_data();
});

$('input[name="table_data[]"]').on('change', function () {
check_table_selected($(this).closest('tr'));
check_table_select_all();
handleAddProcCheckbox();
check_table_select_struture_or_data();
});

$('#table_structure_all').on('change', function () {
toggle_table_select_all_str();
check_selected_tables();
handleAddProcCheckbox();
check_table_select_struture_or_data();
});

$('#table_data_all').on('change', function () {
toggle_table_select_all_data();
check_selected_tables();
handleAddProcCheckbox();
check_table_select_struture_or_data();
});

if ($('input[name=\'export_type\']').val() === 'database') {
Expand Down
9 changes: 7 additions & 2 deletions libraries/classes/Plugins/Export/ExportSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1771,8 +1771,13 @@ public function getTableDef(
if (isset($GLOBALS['sql_auto_increment'])
&& ($statement->entityOptions->has('AUTO_INCREMENT') !== false)
) {
$sql_auto_increments_query .= ', AUTO_INCREMENT='
. $statement->entityOptions->has('AUTO_INCREMENT');
if (!isset($GLOBALS['table_data'])
|| (isset($GLOBALS['table_data'])
&& in_array($table, $GLOBALS['table_data']))
) {
$sql_auto_increments_query .= ', AUTO_INCREMENT='
. $statement->entityOptions->has('AUTO_INCREMENT');
}
}
$sql_auto_increments_query .= ';' . $crlf;

Expand Down