1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-08 23:57:29 +02:00

PostgreSQL: Fix exporting string default values (thanks to PotatoPangolin)

This commit is contained in:
Jakub Vrana
2018-02-09 15:29:54 +01:00
parent ea4ac5c8f3
commit eeb7ce1939
3 changed files with 12 additions and 4 deletions

View File

@@ -195,19 +195,26 @@ function process_type($field, $collate = "COLLATE") {
* @return array array("field", "type", "NULL", "DEFAULT", "ON UPDATE", "COMMENT", "AUTO_INCREMENT")
*/
function process_field($field, $type_field) {
global $jush;
$default = $field["default"];
return array(
idf_escape(trim($field["field"])),
process_type($type_field),
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
(isset($default) ? " DEFAULT " . (preg_match('~char|binary|text|enum|set~', $field["type"]) || preg_match('~^(?![a-z])~i', $default) ? q($default) : $default) : ""),
default_value($field),
(preg_match('~timestamp|datetime~', $field["type"]) && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
($field["auto_increment"] ? auto_increment() : null),
);
}
/** Get default value clause
* @param array
* @return string
*/
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));
}
/** Get type class to use in CSS
* @param string
* @return string class=''