Navigation Menu

Skip to content

Commit

Permalink
Miscellaneous fix while trying to fix the selenium tests
Browse files Browse the repository at this point in the history
+ 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
ioguix committed Jul 14, 2009
1 parent 2d92e82 commit 4ed95f9
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 72 deletions.
26 changes: 13 additions & 13 deletions all_db.php
Expand Up @@ -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";

Expand Down
4 changes: 1 addition & 3 deletions classes/database/Postgres.php
Expand Up @@ -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
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down
2 changes: 0 additions & 2 deletions constraints.php
Expand Up @@ -465,8 +465,6 @@ function cnPre(&$rowdata) {
),
);

if (!$data->hasConstraintsInfo()) unset($columns['comment']);

$actions = array(
'drop' => array(
'title' => $lang['strdrop'],
Expand Down
3 changes: 1 addition & 2 deletions tables.php
Expand Up @@ -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');
Expand Down
83 changes: 38 additions & 45 deletions tblproperties.php
Expand Up @@ -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)
Expand All @@ -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'],
),
Expand All @@ -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']}");
Expand Down
2 changes: 2 additions & 0 deletions tests/selenium/src/04-database.php
Expand Up @@ -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*/
Expand Down
2 changes: 1 addition & 1 deletion tests/selenium/src/25-column.php
Expand Up @@ -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');
Expand Down
11 changes: 5 additions & 6 deletions views.php
Expand Up @@ -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

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 4ed95f9

Please sign in to comment.