Minor fix to same_schema for dead columns. Tweak tests for same.
authorGreg Sabino Mullane <[email protected]>
Fri, 29 Jan 2010 17:05:18 +0000 (12:05 -0500)
committerGreg Sabino Mullane <[email protected]>
Fri, 29 Jan 2010 17:05:18 +0000 (12:05 -0500)
check_postgres.pl
t/02_same_schema.t

index efba51f3e9b6c1f67c159257195229e0a38befd6..eea9b4cc780e2957d393494b0cf34a704cce2316 100755 (executable)
@@ -4684,7 +4684,7 @@ sub check_same_schema {
                        . q{COALESCE(numeric_precision, 0), }
                        . q{COALESCE(numeric_scale,0) }
                        . q{FROM information_schema.columns }
-                       . q{ORDER BY table_schema, table_name, column_name, ordinal_position};
+                       . q{ORDER BY table_schema, table_name, ordinal_position, column_name};
                $info = run_command($SQL, { dbuser => $opt{dbuser}[$x-1], dbnumber => $x } );
                my $oldrelation = '';
                my $col = 0;
index 9514e2507868f6df24c4e3fc849a56f96c9075fc..95ea668035a3445aba37cc0475223c14b267ddf0 100644 (file)
@@ -6,7 +6,7 @@ use 5.006;
 use strict;
 use warnings;
 use Data::Dumper;
-use Test::More tests => 46;
+use Test::More tests => 47;
 use lib 't','.';
 use CP_Testing;
 
@@ -342,13 +342,24 @@ like ($cp1->run($stdargs),
       qr{^$label CRITICAL.*Items not matched: 1\b.*length is 20 on 1, but 40 on 2},
       $t);
 
-$t = qq{$S fails when tables have columns in different orders};
-$dbh1->do(q{ALTER TABLE table_1_only ADD COLUMN buzz date});
+$t = qq{$S works when tables have columns in different orders due to dropped columns};
+$dbh1->do(q{ALTER TABLE table_1_only DROP COLUMN extra});
 $dbh2->do(q{ALTER TABLE table_1_only DROP COLUMN extra});
+$dbh1->do(q{ALTER TABLE table_1_only ADD COLUMN buzz date});
 $dbh2->do(q{ALTER TABLE table_1_only ADD COLUMN buzz date});
-$dbh2->do(q{ALTER TABLE table_1_only ADD COLUMN extra varchar(20)});
+$dbh2->do(q{ALTER TABLE table_1_only DROP COLUMN buzz});
+$dbh2->do(q{ALTER TABLE table_1_only ADD COLUMN buzz date});
+like ($cp1->run($stdargs),
+      qr{^$label OK:},
+      $t);
+
+$t = qq{$S fails when tables have columns in different orders};
+$dbh1->do(q{ALTER TABLE table_1_only ADD COLUMN paris TEXT});
+$dbh1->do(q{ALTER TABLE table_1_only ADD COLUMN rome TEXT});
+$dbh2->do(q{ALTER TABLE table_1_only ADD COLUMN rome TEXT});
+$dbh2->do(q{ALTER TABLE table_1_only ADD COLUMN paris TEXT});
 like ($cp1->run($stdargs),
-      qr{^$label CRITICAL.*Items not matched: 1\b.*position is 2 on 1, but 4 on 2},
+      qr{^$label CRITICAL.*Items not matched: 2\b.*position is 3 on 1, but 4 on 2},
       $t);
 
 $dbh1->do('DROP TABLE table_1_only');