File: xort-style.t

package info (click to toggle)
libdbix-dbstag-perl 0.12-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,420 kB
  • sloc: perl: 6,152; sql: 588; xml: 221; lisp: 59; makefile: 20
file content (60 lines) | stat: -rw-r--r-- 1,309 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use lib 't';

BEGIN {
    # to handle systems with no installed Test module
    # we include the t dir (where a copy of Test.pm is located)
    # as a fallback
    eval { require Test; };
    use Test;    
    use DBStagTest;
    plan tests => 3;
}
use DBIx::DBStag;
use DBI;
use Data::Stag;
use FileHandle;
use strict;

drop();
my $dbh = connect_to_cleandb();

my $f = "parts-schema.sql";
open(F, "t/data/$f") || die;
my $ddl = join('',<F>);
close(F);
$dbh->do($ddl);

$f = "parts-data.xml";
print "parsing..\n";
my $chado  = Data::Stag->parse("t/data/$f");
print "parsed; now storing..\n";
$dbh->storenode($_) foreach $chado->subnodes;

ok(1);
my $cset =
  $dbh->selectall_stag(q[
SELECT * 
FROM component
 LEFT OUTER JOIN part_of ON (component.component_id=part_of.object_id)
 LEFT OUTER JOIN component AS c2 ON (c2.component_id=part_of.subject_id)
USE NESTING (set(component(part_of(c2))))
]);
print $cset->xml;
my @cs = $cset->get_component;
ok(@cs,5);

$cset =
  $dbh->selectall_stag(q[
SELECT component.*
FROM component
 INNER JOIN part_of ON (component.component_id=part_of.subject_id)
 INNER JOIN component AS c2 ON (c2.component_id=part_of.object_id)
WHERE c2.name='1b'
]);

print $cset->xml;
my @names = sort $cset->find_name;
print "names=@names\n";
ok("@names", "1b-I 1b-II");

$dbh->disconnect;