pg: Initial support for receiving binary results
Just the initial framework stuff and a few types to test with.
This commit is contained in:
parent
7c8473533d
commit
8f94dd0921
4 changed files with 164 additions and 34 deletions
28
t/pgtypes.t
Normal file
28
t/pgtypes.t
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use v5.36;
|
||||
use Test::More;
|
||||
no warnings 'experimental::builtin';
|
||||
use builtin qw/true false is_bool created_as_number/;
|
||||
|
||||
plan skip_all => $@ if !eval { require FU::PG; } && $@ =~ /Unable to load libpq/;
|
||||
die $@ if $@;
|
||||
plan skip_all => 'Please set FU_TEST_DB to a PostgreSQL connection string to run these tests' if !$ENV{FU_TEST_DB};
|
||||
|
||||
my $conn = FU::PG->connect($ENV{FU_TEST_DB});
|
||||
$conn->_debug_trace(0);
|
||||
|
||||
sub v($type, $v, $sql=$v) {
|
||||
$sql = "($sql)::$type";
|
||||
my $res = $conn->q("SELECT $sql")->text_results(0)->val;
|
||||
ok is_bool($res), "recv bool $sql" if $type eq 'bool';
|
||||
ok created_as_number($res), "recv number $sql" if $type =~ /^int/;
|
||||
is $res, $v, "recv value $sql";
|
||||
}
|
||||
|
||||
v bool => true, 'true';
|
||||
v bool => false, 'false';
|
||||
|
||||
v int2 => $_ for (1, -1, -32768, 32767, 12345, -12345);
|
||||
v int4 => $_ for (1, -1, -2147483648, 2147483647, 1234567890, -1234567890);
|
||||
v int8 => $_ for (1, -1, -9223372036854775808, 9223372036854775807, 1234567890123456789, -1234567890123456789);
|
||||
|
||||
done_testing;
|
||||
Loading…
Add table
Add a link
Reference in a new issue