Help language development. Donate to The Perl Foundation

DB::Pg cpan:CTILMES last updated on 2021-07-02

use Test;
use Test::When <extended>;

use DB::Pg;

plan 14;

my $pg =;

is $pg.query('select 42').value, 42, 'value int';

nok $pg.query('select 1 where 1=2').value, 'No value';

is $pg.query('select $1::int', 42).value, 42, 'value int placeholder';

is $pg.query("select 'this'").value, 'this', 'value string';

is $pg.query('select $1::text', 'this').value, 'this',
    'value string placeholder';

is $pg.query("select 42e43").value, 42e43, 'value float';

is $pg.query('select $1::float8',42e43).value, 42e43, 'value float placeholder';

my $buf =,2,3,4);

is $pg.query('select $1::bytea', $buf).value, $buf, 'value bytea placeholder';

is $pg.query("select 't'::bool").value, True, 'value bool';

is $pg.query('select $1::bool', False).value, False, 'value bool placeholder';

ok $pg.query('select null').value ~~ Any, 'Null';

is $pg.query('select $1::text', Str).value, Str, 'Null String placeholder';

is $pg.query("select '2000-01-01'::date").value,,1,1), 'date';

is $pg.query("select '2000-01-01'::timestamp").value,,1,1,0,0,0), 'timestamp';