Skip to content

Commit

Permalink
Merge branch 'QA_4_4'
Browse files Browse the repository at this point in the history
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
  • Loading branch information
madhuracj committed Mar 6, 2015
2 parents 1f0ab51 + 4b057ae commit dee38cc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 54 deletions.
27 changes: 18 additions & 9 deletions db_central_columns.php
Expand Up @@ -117,17 +117,26 @@
$odd_row = false;
$row_num=0;
foreach ($result as $row) {
if (is_object(json_decode($row['col_extra']))) {
//Decode the json data of col_extra to col_extra and col_attribute
$row['col_extra'] = json_decode($row['col_extra'], true);
$vals = explode(',', $row['col_extra']);

if (in_array('BINARY', $vals)) {
$row['col_attribute'] = 'BINARY';
} elseif (in_array('UNSIGNED', $vals)) {
$row['col_attribute'] = 'UNSIGNED';
} elseif (in_array('UNSIGNED ZEROFILL', $vals)) {
$row['col_attribute'] = 'UNSIGNED ZEROFILL';
} elseif (in_array('on update CURRENT_TIMESTAMP', $vals)) {
$row['col_attribute'] = 'on update CURRENT_TIMESTAMP';
} else {
//it is not json string [FOR the case to handle previous inserted value]
//like extra column having only increment value,then to deal with it
$row['col_extra'] = array(
"col_extra" => $row['col_extra'],
"col_attribute" => ""
);
$row['col_attribute'] = '';
}

if (in_array('auto_increment', $vals)) {
$row['col_extra'] = 'auto_increment';
} else {
$row['col_extra'] = '';
}

$tableHtmlRow = PMA_getHTMLforCentralColumnsTableRow(
$row, $odd_row, $row_num, $db
);
Expand Down
34 changes: 10 additions & 24 deletions js/functions.js
Expand Up @@ -2938,11 +2938,11 @@ function autoPopulate(input_id, offset)
$('#'+input_id+'4').next().next().hide();
}
$('#'+input_id+'5').val(central_column_list[db+'_'+table][offset].col_collation);
$('#'+input_id+'6').val(central_column_list[db+'_'+table][offset].extra.col_attribute);
if(central_column_list[db+'_'+table][offset].extra.col_extra === 'on update CURRENT_TIMESTAMP') {
$('#'+input_id+'6').val(central_column_list[db+'_'+table][offset].extra.col_extra);
$('#'+input_id+'6').val(central_column_list[db+'_'+table][offset].col_attribute);
if(central_column_list[db+'_'+table][offset].col_extra === 'on update CURRENT_TIMESTAMP') {
$('#'+input_id+'6').val(central_column_list[db+'_'+table][offset].col_extra);
}
if(central_column_list[db+'_'+table][offset].extra.col_extra.toUpperCase() === 'AUTO_INCREMENT') {
if(central_column_list[db+'_'+table][offset].col_extra.toUpperCase() === 'AUTO_INCREMENT') {
$('#'+input_id+'9').prop("checked",true).change();
} else {
$('#'+input_id+'9').prop("checked",false);
Expand Down Expand Up @@ -3155,26 +3155,18 @@ AJAX.registerOnload('functions.js', function () {
var list_size = central_column_list[db + '_' + table].length;
var min = (list_size <= maxRows) ? list_size : maxRows;
for (i = 0; i < min; i++) {
try {
central_column_list[db + '_' + table][i].extra = $.parseJSON(central_column_list[db + '_' + table][i].col_extra);
} catch (error) {
//it is not json encoded so make it [FOR the case to handle previous inserted values]
//like extra column having only increment value,then to deal with it
central_column_list[db + '_' + table][i].col_extra = '{"col_extra":"'+central_column_list[db + '_' + table][i].col_extra+'","col_attribute":""}';
central_column_list[db + '_' + table][i].extra = $.parseJSON(central_column_list[db + '_' + table][i].col_extra);
}

fields += '<tr><td><div><span style="font-size:14px; font-weight:bold">' +
escapeHtml(central_column_list[db + '_' + table][i].col_name) +
'</span><br><span style="color:gray">' + central_column_list[db + '_' + table][i].col_type;

if (central_column_list[db + '_' + table][i].extra.col_attribute !== '') {
fields += '(' + escapeHtml(central_column_list[db + '_' + table][i].extra.col_attribute) + ') ';
if (central_column_list[db + '_' + table][i].col_attribute !== '') {
fields += '(' + escapeHtml(central_column_list[db + '_' + table][i].col_attribute) + ') ';
}
if (central_column_list[db + '_' + table][i].col_length !== '') {
fields += '(' + escapeHtml(central_column_list[db + '_' + table][i].col_length) +') ';
}
fields += escapeHtml(central_column_list[db + '_' + table][i].extra.col_extra) + '</span>' +
fields += escapeHtml(central_column_list[db + '_' + table][i].col_extra) + '</span>' +
'</div></td>';
if (pick) {
fields += '<td><input class="pick" style="width:100%" type="submit" value="' +
Expand Down Expand Up @@ -3226,25 +3218,19 @@ AJAX.registerOnload('functions.js', function () {
fields = '';
min = (list_size <= maxRows + result_pointer) ? list_size : maxRows + result_pointer;
for (i = result_pointer; i < min; i++) {
try {
central_column_list[db + '_' + table][i].extra = $.parseJSON(central_column_list[db + '_' + table][i].col_extra);
} catch (error) {
central_column_list[db + '_' + table][i].col_extra = '{"col_extra":"'+central_column_list[db + '_' + table][i].col_extra+'","col_attribute":""}';
central_column_list[db + '_' + table][i].extra = $.parseJSON(central_column_list[db + '_' + table][i].col_extra);
}

fields += '<tr><td><div><span style="font-size:14px; font-weight:bold">' +
central_column_list[db + '_' + table][i].col_name +
'</span><br><span style="color:gray">' +
central_column_list[db + '_' + table][i].col_type;

if (central_column_list[db + '_' + table][i].extra.col_attribute !== '') {
fields += '(' + central_column_list[db + '_' + table][i].extra.col_attribute + ') ';
if (central_column_list[db + '_' + table][i].col_attribute !== '') {
fields += '(' + central_column_list[db + '_' + table][i].col_attribute + ') ';
}
if (central_column_list[db + '_' + table][i].col_length !== '') {
fields += '(' + central_column_list[db + '_' + table][i].col_length + ') ';
}
fields += central_column_list[db + '_' + table][i].extra.col_extra + '</span>' +
fields += central_column_list[db + '_' + table][i].col_extra + '</span>' +
'</div></td>';
if (pick) {
fields += '<td><input class="pick" style="width:100%" type="submit" value="' +
Expand Down
48 changes: 27 additions & 21 deletions libraries/central_columns.lib.php
Expand Up @@ -188,7 +188,7 @@ function PMA_getInsertQuery($column, $def, $db, $central_list_table)
. '\'' . PMA_Util::sqlAddSlashes($length) . '\',\''
. PMA_Util::sqlAddSlashes($collation) . '\','
. '\'' . PMA_Util::sqlAddSlashes($isNull) . '\','
. '\'' . json_encode(array('col_extra' => $extra, 'col_attribute' => $attribute))
. '\'' . implode(',', array($extra, $attribute))
. '\',\'' . PMA_Util::sqlAddSlashes($default) . '\');';
return $insQuery;
}
Expand Down Expand Up @@ -413,22 +413,34 @@ function PMA_makeConsistentWithList($db, $selected_tables)
if ($column['col_length']) {
$query .= '(' . $column['col_length'] . ')';
}
if (is_object(json_decode($column['col_extra']))) {
$column['col_extra'] = json_decode($column['col_extra'], true);

$vals = explode(',', $column['col_extra']);
if (in_array('BINARY', $vals)) {
$column['col_attribute'] = 'BINARY';
} elseif (in_array('UNSIGNED', $vals)) {
$column['col_attribute'] = 'UNSIGNED';
} elseif (in_array('UNSIGNED ZEROFILL', $vals)) {
$column['col_attribute'] = 'UNSIGNED ZEROFILL';
} elseif (in_array('on update CURRENT_TIMESTAMP', $vals)) {
$column['col_attribute'] = 'on update CURRENT_TIMESTAMP';
} else {
$column['col_extra'] = array(
"col_extra" => $column['col_extra'],
"col_attribute" => ""
);
$column['col_attribute'] = '';
}

if (in_array('auto_increment', $vals)) {
$column['col_extra'] = 'auto_increment';
} else {
$column['col_extra'] = '';
}
$query .= ' ' . $column['col_extra']['col_attribute'];

$query .= ' ' . $column['col_attribute'];
if ($column['col_isNull']) {
$query .= ' NULL';
} else {
$query .= ' NOT NULL';
}

$query .= ' ' . $column['col_extra']['col_extra'];
$query .= ' ' . $column['col_extra'];
if ($column['col_default']) {
if ($column['col_default'] != 'CURRENT_TIMESTAMP') {
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes(
Expand Down Expand Up @@ -538,12 +550,7 @@ function PMA_updateOneColumn($db, $orig_col_name, $col_name, $col_type,
. ', col_length = \'' . PMA_Util::sqlAddSlashes($col_length) . '\''
. ', col_isNull = ' . $col_isNull
. ', col_collation = \'' . PMA_Util::sqlAddSlashes($collation) . '\''
. ', col_extra = \'' . json_encode(
array(
"col_extra" => $col_extra,
"col_attribute" => $col_attribute
)
) . '\''
. ', col_extra = \'' . implode(',', array($col_extra, $col_attribute)) . '\''
. ', col_default = \'' . PMA_Util::sqlAddSlashes($col_default) . '\''
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\' '
. 'AND col_name = \'' . PMA_Util::sqlAddSlashes($orig_col_name)
Expand Down Expand Up @@ -824,11 +831,11 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
$tableHtml .=
'<td class="nowrap" name="col_attribute">'
. '<span>' .
($row['col_extra']['col_attribute']
? htmlspecialchars($row['col_extra']['col_attribute']) : "" )
($row['col_attribute']
? htmlspecialchars($row['col_attribute']) : "" )
. '</span>'
. PMA_getHtmlForColumnAttribute(
$row_num, 4, 0, array(), $row['col_extra']['col_attribute'], false, null
$row_num, 4, 0, array(), $row['col_attribute'], false, null
)
. '</td>';
$tableHtml .=
Expand All @@ -840,11 +847,10 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)

$tableHtml .=
'<td class="nowrap" name="col_extra"><span>'
. htmlspecialchars($row['col_extra']['col_extra']) . '</span>'
. htmlspecialchars($row['col_extra']) . '</span>'
. '<select name="col_extra"><option value=""></option>'
. '<option value="auto_increment">' . __('auto_increment') . '</option>'
. '<option value="on update CURRENT_TIMESTAMP">'
. __('on update CURRENT_TIMESTAMP') . '</option></select>'
. '</select>'
. '</td>';
$meta = array();
if (!isset($row['col_default']) || $row['col_default'] == '') {
Expand Down

0 comments on commit dee38cc

Please sign in to comment.