From 4ed95f93a2f4dd099ede4a0206c47b84c1ac6723 Mon Sep 17 00:00:00 2001 From: "Guillaume (ioguix) de Rorthais" Date: Tue, 14 Jul 2009 01:27:39 -0400 Subject: [PATCH] Miscellaneous fix while trying to fix the selenium tests + fix selenium test when creating a DB under 8.4 with incompatible encoding with template1 (use template0 everytime) + removed hasForeignKeysInfo + removed hasConstraintsInfo + fixed one assertion in the column selenium tests + fixed alterColumn where old name was used to alter the type while the col was renamed in the same transaction + some indentation fixes - SEQUENCE selenium test need to be fixed --- all_db.php | 26 +++++----- classes/database/Postgres.php | 4 +- constraints.php | 2 - tables.php | 3 +- tblproperties.php | 83 ++++++++++++++---------------- tests/selenium/src/04-database.php | 2 + tests/selenium/src/25-column.php | 2 +- views.php | 11 ++-- 8 files changed, 61 insertions(+), 72 deletions(-) diff --git a/all_db.php b/all_db.php index a5f511f4..33131603 100644 --- a/all_db.php +++ b/all_db.php @@ -182,20 +182,20 @@ echo "\t\n\t\t{$lang['strtemplatedb']}\n"; echo "\t\t\n"; echo "\t\t\t\n"; echo "\t\t\n\t\n"; diff --git a/classes/database/Postgres.php b/classes/database/Postgres.php index de6fb876..9b4d0d17 100755 --- a/classes/database/Postgres.php +++ b/classes/database/Postgres.php @@ -2167,7 +2167,7 @@ class Postgres extends ADODB_base { if ($array) $ftype .= '[]'; if ($ftype != $oldtype) { - $toAlter[] = "ALTER COLUMN \"{$column}\" TYPE {$ftype}"; + $toAlter[] = "ALTER COLUMN \"{$name}\" TYPE {$ftype}"; } // Attempt to process the batch alteration, if anything has been changed @@ -7531,7 +7531,6 @@ class Postgres extends ADODB_base { function hasAutovacuumSysTable() { return false; } function hasCasts() { return true; } function hasCompositeTypes() { return true; } - function hasConstraintsInfo() { return true; } function hasConversions() { return true; } function hasCreateTableLike() { return true; } function hasCreateTableLikeWithConstraints() { return true; } @@ -7576,7 +7575,6 @@ class Postgres extends ADODB_base { function hasVirtualTransactionId() { return true; } function hasWithoutOIDs() { return true; } function hasAlterDatabase() { return $this->hasAlterDatabaseRename(); } - function hasForeignKeysInfo() { return $this->hasConstraintsInfo(); } function hasMagicTypes() { return true; } function hasQueryKill() { return true; } function hasConcurrentIndexBuild() { return true; } diff --git a/constraints.php b/constraints.php index ce052aaf..99298c27 100644 --- a/constraints.php +++ b/constraints.php @@ -465,8 +465,6 @@ ), ); - if (!$data->hasConstraintsInfo()) unset($columns['comment']); - $actions = array( 'drop' => array( 'title' => $lang['strdrop'], diff --git a/tables.php b/tables.php index 85fa9633..313c484f 100644 --- a/tables.php +++ b/tables.php @@ -458,8 +458,7 @@ global $data, $misc, $conf; global $lang; - $bAllowAC = (($conf['autocomplete'] != 'disable') ? TRUE : FALSE) - && $data->hasConstraintsInfo(); + $bAllowAC = (($conf['autocomplete'] != 'disable') ? TRUE : FALSE); if ($confirm) { $misc->printTrail('table'); diff --git a/tblproperties.php b/tblproperties.php index 69113691..c08b76d8 100644 --- a/tblproperties.php +++ b/tblproperties.php @@ -458,6 +458,8 @@ $tdata = $data->getTable($_REQUEST['table']); // Get columns $attrs = $data->getTableAttributes($_REQUEST['table']); + // Get constraints keys + $ck = $data->getConstraintsWithFields($_REQUEST['table']); // Show comment if any if ($tdata->fields['relcomment'] !== null) @@ -484,7 +486,15 @@ 'title' => $lang['strdefault'], 'field' => field('adsrc'), ), - 'keyprop' => 1, + 'keyprop' => array( + 'title' => $lang['strconstraints'], + 'field' => field('attname'), + 'type' => 'callback', + 'params'=> array( + 'function' => 'cstrRender', + 'keys' => $ck->getArray() + ) + ), 'actions' => array( 'title' => $lang['stractions'], ), @@ -494,55 +504,38 @@ ), ); - if (!$data->hasConstraintsInfo()) { - unset($columns['keyprop']); - } - else { - $ck = $data->getConstraintsWithFields($_REQUEST['table']); + function cstrRender($s, $p) { + global $misc, $data; - $columns['keyprop'] = array( - 'title' => $lang['strconstraints'], - 'field' => field('attname'), - 'type' => 'callback', - 'params'=> array( - 'function' => 'cstrRender', - 'keys' => $ck->getArray() - ), - ); - - function cstrRender($s, $p) { - global $misc, $data; + $str =''; + foreach ($p['keys'] as $k => $c) { - $str =''; - foreach ($p['keys'] as $k => $c) { - - if (is_null($p['keys'][$k]['consrc'])) { - $atts = $data->getAttributeNames($_REQUEST['table'], explode(' ', $p['keys'][$k]['indkey'])); - $c['consrc'] = ($c['contype'] == 'u' ? "UNIQUE (" : "PRIMARY KEY (") . join(',', $atts) . ')'; - } - - if ($c['p_field'] == $s) - switch ($c['contype']) { - case 'p': - $str .= 'icon('PrimaryKey') .'" alt="[pk]" title="'. htmlentities($c['consrc']) .'" />'; - break; - case 'f': - $str .= 'icon('ForeignKey') .'" alt="[fk]" title="'. htmlentities($c['consrc']) .'" />'; - break; - case 'u': - $str .= 'icon('UniqueConstraint') .'" alt="[uniq]" title="'. htmlentities($c['consrc']) .'" />'; - break; - case 'c': - $str .= 'icon('CheckConstraint') .'" alt="[check]" title="'. htmlentities($c['consrc']) .'" />'; - } + if (is_null($p['keys'][$k]['consrc'])) { + $atts = $data->getAttributeNames($_REQUEST['table'], explode(' ', $p['keys'][$k]['indkey'])); + $c['consrc'] = ($c['contype'] == 'u' ? "UNIQUE (" : "PRIMARY KEY (") . join(',', $atts) . ')'; } - return $str; + if ($c['p_field'] == $s) + switch ($c['contype']) { + case 'p': + $str .= 'icon('PrimaryKey') .'" alt="[pk]" title="'. htmlentities($c['consrc']) .'" />'; + break; + case 'f': + $str .= 'icon('ForeignKey') .'" alt="[fk]" title="'. htmlentities($c['consrc']) .'" />'; + break; + case 'u': + $str .= 'icon('UniqueConstraint') .'" alt="[uniq]" title="'. htmlentities($c['consrc']) .'" />'; + break; + case 'c': + $str .= 'icon('CheckConstraint') .'" alt="[check]" title="'. htmlentities($c['consrc']) .'" />'; + } } + + return $str; } $return_url = urlencode("tblproperties.php?{$misc->href}&table={$_REQUEST['table']}"); diff --git a/tests/selenium/src/04-database.php b/tests/selenium/src/04-database.php index fc64b96f..ad156bbc 100644 --- a/tests/selenium/src/04-database.php +++ b/tests/selenium/src/04-database.php @@ -23,6 +23,8 @@ if ($data->hasAlterDatabaseRename()) $t->type('formName', "{$testdb}toalter"); else $t->type('formName', $testdb); + /* template */ + $t->select('formTemplate', 'template0'); /* encoding*/ $t->select('formEncoding', 'SQL_ASCII'); /* comment*/ diff --git a/tests/selenium/src/25-column.php b/tests/selenium/src/25-column.php index 462b3c75..20ebd73d 100644 --- a/tests/selenium/src/25-column.php +++ b/tests/selenium/src/25-column.php @@ -36,7 +36,7 @@ if ($data->hasCreateFieldWithConstraints()) { $t->assertText("//tr/td/a[text()='new_col']/../../td[3]", ''); $t->assertText("//tr/td/a[text()='new_col']/../../td[4]", '0'); } -$t->assertText("//tr/td/a[text()='new_col']/../../td[9]", 'test col to drop'); +$t->assertText("//tr/td/a[text()='new_col']/../../td[10]", 'test col to drop'); /** 2 **/ $t->addComment('2. alter column'); diff --git a/views.php b/views.php index cd73f98e..056b8fc6 100644 --- a/views.php +++ b/views.php @@ -225,11 +225,10 @@ } $linkCount = $tblCount; - // If we can get foreign key info then get our linking keys - if ($data->hasForeignKeysInfo()) { - $rsLinkKeys = $data->getLinkingKeys($arrSelTables); - $linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount; - } + + //get linking keys + $rsLinkKeys = $data->getLinkingKeys($arrSelTables); + $linkCount = $rsLinkKeys->recordCount() > $tblCount ? $rsLinkKeys->recordCount() : $tblCount; $arrFields = array(); //array that will hold all our table/field names @@ -289,7 +288,7 @@ if (!isset($formLink[$i]['operator'])) $formLink[$i]['operator'] = 'INNER JOIN'; echo "\n\n"; - if ($data->hasForeignKeysInfo() && !$rsLinkKeys->EOF) { + if (!$rsLinkKeys->EOF) { $curLeftLink = htmlspecialchars(serialize(array('schemaname' => $rsLinkKeys->fields['p_schema'], 'tablename' => $rsLinkKeys->fields['p_table'], 'fieldname' => $rsLinkKeys->fields['p_field']) ) ); $curRightLink = htmlspecialchars(serialize(array('schemaname' => $rsLinkKeys->fields['f_schema'], 'tablename' => $rsLinkKeys->fields['f_table'], 'fieldname' => $rsLinkKeys->fields['f_field']) ) ); $rsLinkKeys->moveNext(); -- 2.39.5