Merge pull request #95 from Denitz/skip-dump-of-generated-columns

Skip dump of generated columns
This commit is contained in:
Lionel 2024-03-25 21:00:46 +01:00 committed by GitHub
commit d5ccd05355
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -870,6 +870,7 @@ class Adminer {
$insert = "";
$buffer = "";
$keys = array();
$generatedKeys = array();
$suffix = "";
$fetch_function = ($table != '' ? 'fetch_assoc' : 'fetch_row');
while ($row = $result->$fetch_function()) {
@ -877,6 +878,10 @@ class Adminer {
$values = array();
foreach ($row as $val) {
$field = $result->fetch_field();
if (!empty($fields[$field->name]['generated'])) {
$generatedKeys[$field->name] = true;
continue;
}
$keys[] = $field->name;
$key = idf_escape($field->name);
$values[] = "$key = VALUES($key)";
@ -894,6 +899,10 @@ class Adminer {
$insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES";
}
foreach ($row as $key => $val) {
if (isset($generatedKeys[$key])) {
unset($row[$key]);
continue;
}
$field = $fields[$key];
$row[$key] = ($val !== null
? unconvert_field($field, preg_match(number_type(), $field["type"]) && !preg_match('~\[~', $field["full_type"]) && is_numeric($val) ? $val : q(($val === false ? 0 : $val)))

View file

@ -20,7 +20,6 @@ Joining tables - PRIMARY KEY (table, joining)
Rank, Tree structure
MySQL:
Generated columns (MySQL >= 5.7.6)
Data longer than max_allowed_packet can be sent by mysqli_stmt_send_long_data()
MariaDB: