summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume (ioguix) de Rorthais2009-07-14 05:27:39 +0000
committerGuillaume (ioguix) de Rorthais2009-07-14 05:27:39 +0000
commit4ed95f93a2f4dd099ede4a0206c47b84c1ac6723 (patch)
tree5aca0d5fcca3143179b22aee12052d3edebbbef8
parent2d92e827347afe90e46043addde3ad2e3c0c69a2 (diff)
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
-rw-r--r--all_db.php26
-rwxr-xr-xclasses/database/Postgres.php4
-rw-r--r--constraints.php2
-rw-r--r--tables.php3
-rw-r--r--tblproperties.php83
-rw-r--r--tests/selenium/src/04-database.php2
-rw-r--r--tests/selenium/src/25-column.php2
-rw-r--r--views.php11
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<tr>\n\t\t<th class=\"data left required\">{$lang['strtemplatedb']}</th>\n";
echo "\t\t<td class=\"data1\">\n";
echo "\t\t\t<select name=\"formTemplate\">\n";
- // Always offer template0 and template1
- echo "\t\t\t\t<option value=\"template0\"",
- ($_POST['formTemplate'] == 'template0') ? ' selected="selected"' : '', ">template0</option>\n";
- echo "\t\t\t\t<option value=\"template1\"",
- ($_POST['formTemplate'] == 'template1') ? ' selected="selected"' : '', ">template1</option>\n";
- while (!$templatedbs->EOF) {
- $dbname = htmlspecialchars($templatedbs->fields['datname']);
- if ($dbname != 'template1') {
- // filter out for $conf[show_system] users so we dont get duplicates
- echo "\t\t\t\t<option value=\"{$dbname}\"",
- ($dbname == $_POST['formTemplate']) ? ' selected="selected"' : '', ">{$dbname}</option>\n";
- }
- $templatedbs->moveNext();
+ // Always offer template0 and template1
+ echo "\t\t\t\t<option value=\"template0\"",
+ ($_POST['formTemplate'] == 'template0') ? ' selected="selected"' : '', ">template0</option>\n";
+ echo "\t\t\t\t<option value=\"template1\"",
+ ($_POST['formTemplate'] == 'template1') ? ' selected="selected"' : '', ">template1</option>\n";
+ while (!$templatedbs->EOF) {
+ $dbname = htmlspecialchars($templatedbs->fields['datname']);
+ if ($dbname != 'template1') {
+ // filter out for $conf[show_system] users so we dont get duplicates
+ echo "\t\t\t\t<option value=\"{$dbname}\"",
+ ($dbname == $_POST['formTemplate']) ? ' selected="selected"' : '', ">{$dbname}</option>\n";
}
+ $templatedbs->moveNext();
+ }
echo "\t\t\t</select>\n";
echo "\t\t</td>\n\t</tr>\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 .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
- $misc->icon('PrimaryKey') .'" alt="[pk]" title="'. htmlentities($c['consrc']) .'" /></a>';
- break;
- case 'f':
- $str .= '<a href="tblproperties.php?'. $misc->href ."&amp;table={$c['f_table']}&amp;schema={$c['f_schema']}\"><img src=\"".
- $misc->icon('ForeignKey') .'" alt="[fk]" title="'. htmlentities($c['consrc']) .'" /></a>';
- break;
- case 'u':
- $str .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
- $misc->icon('UniqueConstraint') .'" alt="[uniq]" title="'. htmlentities($c['consrc']) .'" /></a>';
- break;
- case 'c':
- $str .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
- $misc->icon('CheckConstraint') .'" alt="[check]" title="'. htmlentities($c['consrc']) .'" /></a>';
- }
+ 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 .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('PrimaryKey') .'" alt="[pk]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'f':
+ $str .= '<a href="tblproperties.php?'. $misc->href ."&amp;table={$c['f_table']}&amp;schema={$c['f_schema']}\"><img src=\"".
+ $misc->icon('ForeignKey') .'" alt="[fk]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'u':
+ $str .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('UniqueConstraint') .'" alt="[uniq]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ break;
+ case 'c':
+ $str .= '<a href="constraints.php?'. $misc->href ."&amp;table={$c['p_table']}&amp;schema={$c['p_schema']}\"><img src=\"".
+ $misc->icon('CheckConstraint') .'" alt="[check]" title="'. htmlentities($c['consrc']) .'" /></a>';
+ }
}
+
+ return $str;
}
$return_url = urlencode("tblproperties.php?{$misc->href}&amp;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 "<tr>\n<td class=\"$rowClass\">\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();