1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-30 01:30:12 +02:00

PostgreSQL: Fix exporting CREATE TABLE query with GENERATED default values

Thanks to GottfriedCP (https://github.com/adminerevo/adminerevo/issues/157)
This commit is contained in:
Peter Knut
2024-09-17 17:01:17 +02:00
parent 5bc4ac6c18
commit 353cd452a3

View File

@@ -238,7 +238,15 @@ function process_field($field, $type_field) {
*/
function default_value($field) {
$default = $field["default"];
return ($default === null ? "" : " DEFAULT " . (preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default) ? q($default) : $default));
if ($default === null) return "";
if (preg_match('~^GENERATED ~i', $default)) {
return " $default";
}
$quote = preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default);
return " DEFAULT " . ($quote ? q($default) : $default);
}
/** Get type class to use in CSS