}
## Figure out the length of each item for a pretty display
- my ($maxid,$maxname,$maxdb) = (1,1,1);
+ my ($maxid,$maxname,$maxdb,$maxpk) = (1,1,1,1);
for my $row (values %$TABLE) {
my $id = $row->{id};
next if @nouns and ! exists $matchtable{$id};
my $name = "$row->{schemaname}.$row->{tablename}";
$maxname = length $name if length $name > $maxname;
$maxdb = length $row->{db} if length $row->{db} > $maxdb;
+ $row->{ppk} = $row->{pkey} ? "$row->{pkey} ($row->{pkeytype})" : 'none';
+ $maxpk = length $row->{ppk} if length $row->{ppk} > $maxpk;
}
## Now do the actual printing
## Sort by schemaname then tablename
- for my $row (sort {
- $a->{schemaname} cmp $b->{schemaname}
- or
- $a->{tablename} cmp $b->{tablename}
- } values %$TABLE) {
+ for my $row (sort numbered_relations values %$TABLE) {
next if @nouns and ! exists $matchtable{$row->{id}};
- printf '%-*s Table: %-*s Database: %-*s',
+ printf '%-*s Table: %-*s DB: %-*s PK: %-*s',
1+$maxid, "$row->{id}.",
$maxname, "$row->{schemaname}.$row->{tablename}",
- $maxdb, $row->{db};
+ $maxdb, $row->{db},
+ $maxpk, $row->{ppk};
if ($row->{sync}) {
- printf ' Syncs: ';
+ printf ' Syncs: ';
print join ',' => sort keys %{ $row->{sync} };
}
+ if (defined $row->{ping}) {
+ printf ' ping:%s', $row->{ping} ? 'true' : 'false';
+ }
+ if ($row->{rebuild_index}) {
+ print ' rebuild_index:true';
+ }
print "\n";
$VERBOSE >= 2 and show_all_columns($row);
$t = q{'bucardo list tables' returns expected result};
$res = $bct->ctl('bucardo list tables');
$expected =
-q{Table: public.bucardo_test1 DB: A PK: id (int2)
-Table: public.bucardo_test2 DB: A PK: id|data1 (int4|text)
-Table: public.bucardo_test3 DB: A PK: id (int8)
-Table: public.bucardo_test4 DB: A PK: id (text)
-Table: public.bucardo_test5 DB: A PK: id space (date)
-Table: public.bucardo_test6 DB: A PK: id (timestamp)
-Table: public.bucardo_test7 DB: A PK: id (numeric)
-Table: public.bucardo_test8 DB: A PK: id (bytea)
-Table: public.bucardo_test9 DB: A PK: id (int_unsigned)
-Table: public.bucardo_test10 DB: A PK: id (timestamptz)
-Table: public.droptest DB: A PK: none
-Table: tschema.bucardo_test3 DB: A PK: none
+qr{\d+\.\s* Table: public.bucardo_test1 DB: A PK: id \(int2\)\s+
+\d+\.\s* Table: public.bucardo_test2 DB: A PK: id\|data1 \(int4\|text\)
+\d+\.\s* Table: public.bucardo_test3 DB: A PK: id \(int8\)\s+
+\d+\.\s* Table: public.bucardo_test4 DB: A PK: id \(text\)\s+
+\d+\.\s* Table: public.bucardo_test5 DB: A PK: id space \(date\)\s+
+\d+\.\s* Table: public.bucardo_test6 DB: A PK: id \(timestamp\)\s+
+\d+\.\s* Table: public.bucardo_test7 DB: A PK: id \(numeric\)\s+
+\d+\.\s* Table: public.bucardo_test8 DB: A PK: id \(bytea\)\s+
+\d+\.\s* Table: public.bucardo_test9 DB: A PK: id \(int_unsigned\)\s+
+\d+\.\s* Table: public.bucardo_test10 DB: A PK: id \(timestamptz\)\s+
+\d+\.\s* Table: public.droptest DB: A PK: none\s+
+\d+\.\s* Table: tschema.bucardo_test3 DB: A PK: none\s+
};
-is ($res, $expected, $t);
+like ($res, $expected, $t);
## Remove them all, then try adding in various combinations
empty_goat_table();
$t = q{'bucardo list tables' returns expected result};
$res = $bct->ctl('bucardo list tables');
$expected =
-q{Table: public.bucardo_test1 DB: A PK: id (int2)
-Table: public.bucardo_test2 DB: A PK: id|data1 (int4|text)
-Table: public.bucardo_test4 DB: A PK: id (text) ping:true
-Table: public.bucardo_test9 DB: A PK: id (int_unsigned)
+qr{\d+\.\s* Table: public.bucardo_test1 DB: A PK: id \(int2\)\s*
+\d+\.\s* Table: public.bucardo_test2 DB: A PK: id\|data1 \(int4\|text\)\s*
+\d+\.\s* Table: public.bucardo_test4 DB: A PK: id \(text\)\s* ping:true\s*
+\d+\.\s* Table: public.bucardo_test9 DB: A PK: id \(int_unsigned\)\s*
};
-is ($res, $expected, $t);
+like ($res, $expected, $t);
$t = q{Add table works when specifying the rebuild_index and ping options};
$res = $bct->ctl('bucardo add table bucardo_test5 ping=false rebuild_index=1');
$t = q{'bucardo list tables' returns expected result};
$res = $bct->ctl('bucardo list tables');
$expected =
-q{Table: public.bucardo_test1 DB: A PK: id (int2)
-Table: public.bucardo_test2 DB: A PK: id|data1 (int4|text)
-Table: public.bucardo_test4 DB: A PK: id (text) ping:true
-Table: public.bucardo_test5 DB: A PK: id space (date) ping:false rebuild_index:1
-Table: public.bucardo_test9 DB: A PK: id (int_unsigned)
+qr{\d+\.\s* Table: public.bucardo_test1 DB: A PK: id \(int2\)\s*
+\d+\.\s* Table: public.bucardo_test2 DB: A PK: id|data1 \(int4\|text\)\s*
+\d+\.\s* Table: public.bucardo_test4 DB: A PK: id \(text\)\s* ping:true\s*
+\d+\.\s* Table: public.bucardo_test5 DB: A PK: id space \(date\)\s* ping:false\s* rebuild_index:true\s*
+\d+\.\s* Table: public.bucardo_test9 DB: A PK: id \(int_unsigned\)\s*
};
-is ($res, $expected, $t);
+like ($res, $expected, $t);
empty_goat_table();