Skip to content
Browse files

Fix alter table

  • Loading branch information...
1 parent 44d572e commit 736d6e43f45a194d7a37a83ab6dd3cfd3d4fb318 @vrana committed May 5, 2010
Showing with 8 additions and 8 deletions.
  1. +7 −7 adminer/drivers/pgsql.inc.php
  2. +1 −1 adminer/include/editing.inc.php
View
14 adminer/drivers/pgsql.inc.php
@@ -329,7 +329,7 @@ function rename_database($name, $collation) {
}
function auto_increment() {
- return true;
+ return "";
}
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
@@ -344,23 +344,23 @@ function alter_table($table, $name, $fields, $foreign, $comment, $engine, $colla
} else {
$val5 = $val[5];
unset($val[5]);
- if ($val[6]) { // auto_increment
- $val = array($val[0], ($val[1] == "bigint" ? "big" : "") . "serial");
+ if (isset($val[6]) && $field[0] == "") { // auto_increment
+ $val[1] = ($val[1] == "bigint" ? " big" : " ") . "serial";
}
if ($field[0] == "") {
$alter[] = ($table != "" ? "ADD " : " ") . implode("", $val);
} else {
if ($column != $val[0]) {
$queries[] = "ALTER TABLE " . idf_escape($table) . " RENAME $column TO $val[0]";
}
- $alter[] = "ALTER $column TYPE $val[1]";
+ $alter[] = "ALTER $column TYPE$val[1]";
if (!$val[6]) {
- $alter[] = "ALTER $column" . ($val[3] ? " SET$val[3]" : " DROP DEFAULT"); //! quoting
+ $alter[] = "ALTER $column " . ($val[3] ? "SET$val[3]" : "DROP DEFAULT"); //! quoting
$alter[] = "ALTER $column " . ($val[2] == " NULL" ? "DROP NOT" : "SET") . $val[2];
}
}
- if ($table != "" || $val5 != "") {
- $queries[] = "COMMENT ON COLUMN " . idf_escape($table) . ".$val[0] IS " . substr($val5, 9);
+ if ($field[0] != "" || $val5 != "") {
+ $queries[] = "COMMENT ON COLUMN " . idf_escape($table) . ".$val[0] IS " . ($val5 != "" ? substr($val5, 9) : "''");
}
}
}
View
2 adminer/include/editing.inc.php
@@ -153,7 +153,7 @@ function process_field($field, $type_field) {
(isset($field["default"]) ? " DEFAULT " . ($field["type"] == "timestamp" && eregi("^CURRENT_TIMESTAMP$", $field["default"]) ? $field["default"] : $connection->quote($field["default"])) : ""),
($field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
(support("comment") && $field["comment"] != "" ? " COMMENT " . $connection->quote($field["comment"]) : ""),
- ($field["auto_increment"] ? auto_increment() : ""),
+ ($field["auto_increment"] ? auto_increment() : null),
);
}

0 comments on commit 736d6e4

Please sign in to comment.
Something went wrong with that request. Please try again.