Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit 4ed95f93a2f4dd099ede4a0206c47b84c1ac6723 1 parent 2d92e82
@ioguix ioguix authored
View
26 all_db.php
@@ -182,20 +182,20 @@ function doCreate($msg = '') {
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";
View
4 classes/database/Postgres.php
@@ -2167,7 +2167,7 @@ function alterColumn($table, $column, $name, $notnull, $oldnotnull, $default, $o
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 @@ function hasAutovacuum() { return true; }
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 @@ function hasViewColumnRename() { return true; }
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; }
View
2  constraints.php
@@ -465,8 +465,6 @@ function cnPre(&$rowdata) {
),
);
- if (!$data->hasConstraintsInfo()) unset($columns['comment']);
-
$actions = array(
'drop' => array(
'title' => $lang['strdrop'],
View
3  tables.php
@@ -458,8 +458,7 @@ function doInsertRow($confirm, $msg = '') {
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');
View
83 tblproperties.php
@@ -458,6 +458,8 @@ function attPre(&$rowdata, $actions) {
$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 @@ function attPre(&$rowdata, $actions) {
'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 @@ function attPre(&$rowdata, $actions) {
),
);
- 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']}");
View
2  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*/
View
2  tests/selenium/src/25-column.php
@@ -36,7 +36,7 @@
$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');
View
11 views.php
@@ -225,11 +225,10 @@ function doSetParamsCreate($msg = '') {
}
$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 @@ function doSetParamsCreate($msg = '') {
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();
Please sign in to comment.
Something went wrong with that request. Please try again.