pg: Minor docs + tests
This commit is contained in:
parent
867543267f
commit
d5401674f9
3 changed files with 31 additions and 1 deletions
|
|
@ -47,8 +47,15 @@ subtest '$st prepare & exec', sub {
|
|||
my $st = $conn->q('SELECT 1');
|
||||
is_deeply $st->param_types, [];
|
||||
is_deeply $st->columns, [{ name => '?column?', oid => 23 }];
|
||||
|
||||
ok !eval { $st->cache; 1 };
|
||||
like $@, qr/Invalid attempt to change statement configuration/;
|
||||
$st = $st->text;
|
||||
|
||||
is $conn->exec('SELECT 1 FROM pg_prepared_statements'), 1;
|
||||
|
||||
is $st->exec, 1;
|
||||
|
||||
ok !eval { $st->exec; 1 };
|
||||
like $@, qr/Invalid attempt to execute statement multiple times/;
|
||||
}
|
||||
|
|
@ -79,6 +86,19 @@ subtest '$st prepare & exec', sub {
|
|||
okerr FATAL => exec => qr/unexpected status code/;
|
||||
|
||||
is $conn->q('SET client_encoding=utf8')->exec, undef;
|
||||
|
||||
ok !eval { $conn->q('select 1; select 2')->exec; 1 };
|
||||
okerr ERROR => prepare => qr/cannot insert multiple commands into a prepared statement/;
|
||||
|
||||
# Interleaved
|
||||
{
|
||||
my $a = $conn->q('SELECT 1 as a');
|
||||
my $b = $conn->q('SELECT 2 as b');
|
||||
is_deeply $a->columns, [ { oid => 23, name => 'a' } ];
|
||||
is_deeply $b->columns, [ { oid => 23, name => 'b' } ];
|
||||
is $a->val, 1;
|
||||
is $b->val, 2;
|
||||
}
|
||||
};
|
||||
|
||||
subtest '$st->val', sub {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue