DBIx-Librarian

 view release on metacpan or  search on metacpan

t/00suite.t  view on Meta::CPAN

		       "t_select_bug") };
ok ($@, "successful prepare");

######################################################################
# INSERT with no bind variable
# SELECT check to verify that one row was inserted

my @results;
eval { @results = $dblbn->execute("t_insert", $data); };

ok($data->{bugid} == 5, "insert, no bind variables");
ok($results[0] == 2
   && $results[1]->[0] == 1
   && $results[1]->[1] == 1, "rowcounts");


# force disconnect to make sure Librarian reconnects correctly
$dblbn->{DBH}->disconnect;

######################################################################
# INSERT with bind variables
# SELECT check to verify that one row was inserted

$data->{groupset} = 17;
$data->{assigned_to} = 9;
$data->{product} = "Perl";
$data->{testnode}->{product_name} = "Perl";
#$data->{product} = [ "foo" ];

eval { $dblbn->execute("t_insert_bind", $data); };

ok($data->{bugid} == 7, "insert, with bind variables");

######################################################################
# multi-column SELECT

eval { $dblbn->execute("t_select_row"); };
ok($@, "Missing target data reference");

$data->{groupset} = 42;

eval { $dblbn->execute("t_select_row", $data); };

ok($data->{bugid} == 5, "single-row select");

eval { $dblbn->execute("t_select_row2", $data); };

ok(defined $data->{foo}, "single-row select with structure");
ok($data->{foo}->{bugid} == 5, "single-row select with structure");

######################################################################
# multi-row SELECT

eval { $dblbn->execute("t_select_all", $data); };

ok(scalar(@{$data->{bug}}) == 2, "multi-row select");

######################################################################
# repeat SELECT

tests/allqueries.msql  view on Meta::CPAN

delete from BUG

;;


t_insert:

# comment here

insert into BUG (
       bugid,
       groupset,
       assigned_to,
       bug_severity,
       bug_status,
       creation_ts,
       op_sys,
#embedded comment
       priority,
       product,
       reporter,

tests/allqueries.msql  view on Meta::CPAN

  current_timestamp,
  "RH",
  "HIGH",
  "DBIx::Librarian",
  3,
  "0.1",
  "Statement",
  ""
)

select1	bugid
from	BUG
where	groupset = 42

;;


t_insert_bind:

insert into BUG (
       bugid,
       groupset,
       assigned_to,
       bug_severity,
       bug_status,
       creation_ts,
       op_sys,
       priority,
       product,
       reporter,
       version,

tests/allqueries.msql  view on Meta::CPAN

  current_timestamp,
  "RH",
  "HIGH",
  :product,
  3,
  "0.1",
  "Statement",
  ""
)

select1	bugid
from	BUG
where	groupset = :groupset

;;


t_select_all:

select	bugid "bug.bugid"
from	BUG

;;


t_select_bug:

select1	reporter,
	version,
	product
from	BUG
where	bugid = :bugid;

;;


t_select_row:

select1	bugid,
	product,
	assigned_to,
	version
from	BUG
where	groupset = :groupset;

;;


t_select_row2:

select1	bugid "foo.bugid",
	product "foo.prodnum",
	assigned_to "foo.assignee",
	version "foo.version"
from	BUG
where	groupset = :groupset;

;;

tests/bugdb.ddl  view on Meta::CPAN

drop table if exists BUG;

create table BUG (
    bugid mediumint not null,
    groupset bigint not null,
    assigned_to mediumint not null, # This is a comment.
    bug_file_loc text,
    bug_severity enum("HIGH", "MED", "LOW") not null,
    bug_status enum("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED") not null,
    creation_ts datetime not null,
    delta_ts timestamp,
    short_desc mediumtext,
    op_sys enum("RH", "SOLARIS", "WIN2K", "MACOSX") not null,
    priority enum("HIGH", "MED", "LOW") not null,

tests/t_insert.sql  view on Meta::CPAN

insert into BUG (
       bugid,
       groupset,
       assigned_to,
       bug_severity,
       bug_status,
       creation_ts,
       op_sys,
# embedded comment
       priority,
       product,
       reporter,

tests/t_insert.sql  view on Meta::CPAN

  "HIGH",
  "DBIx::Librarian",
  3,
  "0.1",
  "Statement",
  ""
)



select1	bugid
from	BUG
where	groupset = 42

tests/t_insert_bind.sql  view on Meta::CPAN

insert into BUG (
       bugid,
       groupset,
       assigned_to,
       bug_severity,
       bug_status,
       creation_ts,
       op_sys,
       priority,
       product,
       reporter,
       version,

tests/t_insert_bind.sql  view on Meta::CPAN

  "HIGH",
  :testnode.product_name,
  3,
  "0.1",
  "Statement",
  ""
)



select1	bugid
from	BUG
where	groupset = :groupset

tests/t_select_all.sql  view on Meta::CPAN

select	bugid "bug.bugid"
from	BUG

tests/t_select_bug.sql  view on Meta::CPAN

select1	reporter,
	version,
	product
from	BUG
where	bugid = :bugid
#  and	(:nothing is null)
;

tests/t_select_row.sql  view on Meta::CPAN

select1	bugid,
	product,
	assigned_to,
	version
from	BUG
where	groupset = :groupset;

tests/t_select_row2.sql  view on Meta::CPAN

select1	bugid "foo.bugid",
	product "foo.prodnum",
	assigned_to "foo.assignee",
	version "foo.version"
from	BUG
where	groupset = :groupset;



( run in 2.289 seconds using v1.01-cache-2.11-cpan-5735350b133 )