Pg: Don't return self on / cache() or text_*() methods
This is much too easy of a footgun: $db->cache->q(...); Enabled cache on the $db object, not just for the given query.
This commit is contained in:
parent
13271fa413
commit
ab168bd952
2 changed files with 7 additions and 3 deletions
|
|
@ -17,7 +17,9 @@ okerr FATAL => connect => qr/missing "=" after "invalid"/;
|
|||
|
||||
ok FU::Pg::lib_version() > 100000;
|
||||
|
||||
my $conn = FU::Pg->connect($ENV{FU_TEST_DB})->text->cache(0);
|
||||
my $conn = FU::Pg->connect($ENV{FU_TEST_DB});
|
||||
$conn->text;
|
||||
$conn->cache(0);
|
||||
$conn->_debug_trace(0);
|
||||
|
||||
is ref $conn, 'FU::Pg::conn';
|
||||
|
|
@ -364,7 +366,9 @@ subtest 'txn', sub {
|
|||
}
|
||||
|
||||
subtest 'Prepared statement cache', sub {
|
||||
my $txn = $conn->cache_size(2)->txn->cache;
|
||||
$conn->cache_size(2);
|
||||
my $txn = $conn->txn;
|
||||
$txn->cache;
|
||||
my sub numexec($sql) {
|
||||
$txn->q('SELECT generic_plans + custom_plans FROM pg_prepared_statements WHERE statement = $1', $sql)->cache(0)->val
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue