Miscellaneous fix while trying to fix the selenium tests
authorGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Tue, 14 Jul 2009 05:27:39 +0000 (01:27 -0400)
committerGuillaume (ioguix) de Rorthais <ioguix@free.fr>
Tue, 14 Jul 2009 05:27:39 +0000 (01:27 -0400)
+ 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
classes/database/Postgres.php
constraints.php
tables.php
tblproperties.php
tests/selenium/src/04-database.php
tests/selenium/src/25-column.php
views.php

index a5f511f48def39dcc837cc2602569a05a18d6ac7..331316031c56bc90f1b86d750b9a4d75cdf79ef8 100644 (file)
                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";
 
index de6fb876142131eaecc2555470036f3f95e73953..9b4d0d172f23e0605bacd4b01a4ead02c3a02abd 100755 (executable)
@@ -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; }
index ce052aafeede1b198d931740a5e7eb199393512f..99298c27bfd7936dc8d1b55215561d7d3bfe5b9b 100644 (file)
                        ),
                );
 
-               if (!$data->hasConstraintsInfo()) unset($columns['comment']);
-
                $actions = array(
                        'drop' => array(
                                'title' => $lang['strdrop'],
index 85fa96334f023d82222bf61da8cdb08d5fa17ea9..313c484f13474c067abf4e96b9404867c6990501 100644 (file)
                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');
index 69113691a4885d90d420825797ef3d9f3d2c0413..c08b76d877a71617133941f149e1cd1c0ac914b4 100644 (file)
                $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)
                                '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'],
                        ),
                        ),
                );
 
-               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']}");
index fc64b96ffe230840267ff896bfa8446785ca2e2e..ad156bbc807be9aeeeb15d1f595b9c486d09fde9 100644 (file)
@@ -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*/
index 462b3c759d986630a78a2dc21509e8ce4794c294..20ebd73de5e03bee38d31e7622cd3f69dc122770 100644 (file)
@@ -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');
index cd73f98efc33d1ec1631e3276304a246ef5b95a0..056b8fc6170a5d1f8fd141449f60221ce0cfc144 100644 (file)
--- a/views.php
+++ b/views.php
                        }
                        
                        $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
                        
                                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();