From 677cca796475b5577420f03c29facc2873cbc885 Mon Sep 17 00:00:00 2001 From: chriskl Date: Tue, 2 Nov 2004 03:33:35 +0000 Subject: [PATCH] fix bug where default and not null clauses were being ignored in add column for 8.0 --- classes/database/Postgres.php | 15 +++++++++++++-- tblproperties.php | 10 +++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index c897b49c..4d07fe43 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -4,7 +4,7 @@ * A class that implements the DB interface for Postgres * Note: This class uses ADODB and returns RecordSets. * - * $Id: Postgres.php,v 1.248 2004/10/11 10:27:33 jollytoad Exp $ + * $Id: Postgres.php,v 1.249 2004/11/02 03:33:35 chriskl Exp $ */ // @@@ THOUGHT: What about inherits? ie. use of ONLY??? @@ -1302,10 +1302,12 @@ class Postgres extends ADODB_base { * @param $column The name of the new column * @param $type The type of the column * @param $array True if array type, false otherwise + * @param $notnull True if NOT NULL, false otherwise + * @param $default The default for the column. '' for none. * @param $length The optional size of the column (ie. 30 for varchar(30)) * @return 0 success */ - function addColumn($table, $column, $type, $array, $length, $comment) { + function addColumn($table, $column, $type, $array, $length, $notnull, $default, $comment) { $this->fieldClean($table); $this->fieldClean($column); $this->clean($type); @@ -1335,6 +1337,15 @@ class Postgres extends ADODB_base { // Add array qualifier, if requested if ($array) $sql .= '[]'; + + // If we have advanced column adding, add the extra qualifiers + if ($this->hasAlterColumnType()) { + // NOT NULL clause + if ($notnull) $sql .= ' NOT NULL'; + + // DEFAULT clause + if ($default != '') $sql .= ' DEFAULT ' . $default; + } $status = $this->beginTransaction(); if ($status != 0) return -1; diff --git a/tblproperties.php b/tblproperties.php index d89d42ec..a11982dd 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -3,7 +3,7 @@ /** * List tables in a database * - * $Id: tblproperties.php,v 1.61 2004/09/07 13:58:21 jollytoad Exp $ + * $Id: tblproperties.php,v 1.62 2004/11/02 03:33:35 chriskl Exp $ */ // Include application functions @@ -280,6 +280,9 @@ echo ""; } + else { + echo "\n"; + } echo ""; echo "\n"; @@ -301,9 +304,10 @@ doAddColumn($lang['strcolneedsname']); return; } - + $status = $data->addColumn($_POST['table'], $_POST['field'], - $_POST['type'], $_POST['array'] != '', $_POST['length'], $_POST['comment']); + $_POST['type'], $_POST['array'] != '', $_POST['length'], isset($_POST['notnull']), + $_POST['default'], $_POST['comment']); if ($status == 0) doDefault($lang['strcolumnadded']); else { -- 2.39.5