From 1814b1a0b78770c8ba9e7a0adef56c4c324d4064 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 26 Aug 2020 08:17:38 +0000 Subject: over: rename ->connect method to ->dbh `->connect' is confused with the perlfunc for the `connect(2)' syscall, and also `DBI->connect'. Since SQLite doesn't use sockets, the word "connect" needlessly confuses me. Give it a short name to match the field name we use for it, which also matches the variable name used by the DBI(3pm) and DBD::SQLite(3pm) manpages. --- t/over.t | 9 ++++----- t/search-thr-index.t | 4 ++-- t/v1reindex.t | 2 +- t/v2reindex.t | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 't') diff --git a/t/over.t b/t/over.t index 8bf64ecb..6c4c8ee6 100644 --- a/t/over.t +++ b/t/over.t @@ -9,7 +9,7 @@ require_mods('DBD::SQLite'); use_ok 'PublicInbox::OverIdx'; my ($tmpdir, $for_destroy) = tmpdir(); my $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); -$over->connect; +$over->dbh; # open file is($over->max, 0, 'max is zero on new DB (scalar context)'); is_deeply([$over->max], [0], 'max is zero on new DB (list context)'); my $x = $over->next_tid; @@ -26,11 +26,10 @@ ok(!$over->{dbh}->{ReadOnly}, 'OverIdx is not ReadOnly'); $over->disconnect; $over = PublicInbox::Over->new("$tmpdir/over.sqlite3"); -$over->connect; -ok($over->{dbh}->{ReadOnly}, 'Over is ReadOnly'); +ok($over->dbh->{ReadOnly}, 'Over is ReadOnly'); $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); -$over->connect; +$over->dbh; is($over->sid('hello-world'), $x, 'idempotent across reopen'); $over->each_by_mid('never', sub { fail('should not be called') }); @@ -71,7 +70,7 @@ SKIP: { skip("no WAL in SQLite version $v < 3.7.0", 1) if $v lt v3.7.0; $over->{dbh}->do('PRAGMA journal_mode = WAL'); $over = PublicInbox::OverIdx->new("$tmpdir/over.sqlite3"); - is($over->connect->selectrow_array('PRAGMA journal_mode'), 'wal', + is($over->dbh->selectrow_array('PRAGMA journal_mode'), 'wal', 'WAL journal_mode not clobbered if manually set'); } diff --git a/t/search-thr-index.t b/t/search-thr-index.t index 914807a8..b5a5ff1f 100644 --- a/t/search-thr-index.t +++ b/t/search-thr-index.t @@ -60,7 +60,7 @@ foreach (reverse split(/\n\n/, $data)) { my $prev; my %tids; -my $dbh = $rw->{over}->connect; +my $dbh = $rw->{over}->dbh; foreach my $mid (@mids) { my $msgs = $rw->{over}->get_thread($mid); is(3, scalar(@$msgs), "got all messages from $mid"); @@ -84,7 +84,7 @@ Message-Id: <1-bw@g> From: bw@g To: git@vger.kernel.org - my $dbh = $rw->{over}->connect; + my $dbh = $rw->{over}->dbh; my ($id, $prev); my $reidx = $rw->{over}->next_by_mid('1-bw@g', \$id, \$prev); ok(defined $reidx); diff --git a/t/v1reindex.t b/t/v1reindex.t index d70ed4b9..a5c85ffb 100644 --- a/t/v1reindex.t +++ b/t/v1reindex.t @@ -434,7 +434,7 @@ ok(!-d $xap, 'Xapian directories removed again'); my $ibx = PublicInbox::Inbox->new({ %$ibx_config }); my $f = $ibx->over->{dbh}->sqlite_db_filename; my $over = PublicInbox::OverIdx->new($f); - my $dbh = $over->connect; + my $dbh = $over->dbh; my $non_ghost_tids = sub { $dbh->selectall_arrayref(<<''); SELECT tid FROM over WHERE num > 0 ORDER BY tid ASC diff --git a/t/v2reindex.t b/t/v2reindex.t index ea2b24e5..a2fc2075 100644 --- a/t/v2reindex.t +++ b/t/v2reindex.t @@ -432,7 +432,7 @@ my $check_rethread = sub { my $ibx = PublicInbox::Inbox->new(\%config); my $f = $ibx->over->{dbh}->sqlite_db_filename; my $over = PublicInbox::OverIdx->new($f); - my $dbh = $over->connect; + my $dbh = $over->dbh; my $non_ghost_tids = sub { $dbh->selectall_arrayref(<<''); SELECT tid FROM over WHERE num > 0 ORDER BY tid ASC -- cgit v1.2.3-24-ge0c7