fixup for stringify that can be false in find_or_create_related
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Setup.pm
1 use strict;
2 use warnings;
3 use DBICTest;
4
5 my $schema = DBICTest->initialise;
6
7 $schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]);
8
9 my $dbh = $schema->storage->dbh;
10
11 if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
12   $schema->deploy;
13 } else {
14   open IN, "t/lib/sqlite.sql";
15
16   my $sql;
17
18   { local $/ = undef; $sql = <IN>; }
19
20   close IN;
21
22   $dbh->do($_) for split(/\n\n/, $sql);
23 }
24
25 $schema->storage->dbh->do("PRAGMA synchronous = OFF");
26
27 $schema->populate('Artist', [
28   [ qw/artistid name/ ],
29   [ 1, 'Caterwauler McCrae' ],
30   [ 2, 'Random Boy Band' ],
31   [ 3, 'We Are Goth' ],
32 ]);
33
34 $schema->populate('CD', [
35   [ qw/cdid artist title year/ ],
36   [ 1, 1, "Spoonful of bees", 1999 ],
37   [ 2, 1, "Forkful of bees", 2001 ],
38   [ 3, 1, "Caterwaulin' Blues", 1997 ],
39   [ 4, 2, "Generic Manufactured Singles", 2001 ],
40   [ 5, 3, "Come Be Depressed With Us", 1998 ],
41 ]);
42
43 $schema->populate('LinerNotes', [
44   [ qw/liner_id notes/ ],
45   [ 2, "Buy Whiskey!" ],
46   [ 4, "Buy Merch!" ],
47   [ 5, "Kill Yourself!" ],
48 ]);
49
50 $schema->populate('Tag', [
51   [ qw/tagid cd tag/ ],
52   [ 1, 1, "Blue" ],
53   [ 2, 2, "Blue" ],
54   [ 3, 3, "Blue" ],
55   [ 4, 5, "Blue" ],
56   [ 5, 2, "Cheesy" ],
57   [ 6, 4, "Cheesy" ],
58   [ 7, 5, "Cheesy" ],
59   [ 8, 2, "Shiny" ],
60   [ 9, 4, "Shiny" ],
61 ]);
62
63 $schema->populate('TwoKeys', [
64   [ qw/artist cd/ ],
65   [ 1, 1 ],
66   [ 1, 2 ],
67   [ 2, 2 ],
68 ]);
69
70 $schema->populate('FourKeys', [
71   [ qw/foo bar hello goodbye/ ],
72   [ 1, 2, 3, 4 ],
73   [ 5, 4, 3, 6 ],
74 ]);
75
76 $schema->populate('OneKey', [
77   [ qw/id artist cd/ ],
78   [ 1, 1, 1 ],
79   [ 2, 1, 2 ],
80   [ 3, 2, 2 ],
81 ]);
82
83 $schema->populate('SelfRef', [
84   [ qw/id name/ ],
85   [ 1, 'First' ],
86   [ 2, 'Second' ],
87 ]);
88
89 $schema->populate('SelfRefAlias', [
90   [ qw/self_ref alias/ ],
91   [ 1, 2 ]
92 ]);
93
94 $schema->populate('ArtistUndirectedMap', [
95   [ qw/id1 id2/ ],
96   [ 1, 2 ]
97 ]);
98
99 $schema->populate('Producer', [
100   [ qw/producerid name/ ],
101   [ 1, 'Matt S Trout' ],
102   [ 2, 'Bob The Builder' ],
103   [ 3, 'Fred The Phenotype' ],
104 ]);
105
106 $schema->populate('CD_to_Producer', [
107   [ qw/cd producer/ ],
108   [ 1, 1 ],
109   [ 1, 2 ],
110   [ 1, 3 ],
111 ]);
112
113 $schema->populate('TreeLike', [
114   [ qw/id parent name/ ],
115   [ 1, 0, 'foo'  ],
116   [ 2, 1, 'bar'  ],
117   [ 3, 2, 'baz'  ],
118   [ 4, 3, 'quux' ],
119 ]);
120
121 $schema->populate('Track', [
122   [ qw/trackid cd  position title/ ],
123   [ 4, 2, 1, "Stung with Success"],
124   [ 5, 2, 2, "Stripy"],
125   [ 6, 2, 3, "Sticky Honey"],
126   [ 7, 3, 1, "Yowlin"],
127   [ 8, 3, 2, "Howlin"],
128   [ 9, 3, 3, "Fowlin"],
129   [ 10, 4, 1, "Boring Name"],
130   [ 11, 4, 2, "Boring Song"],
131   [ 12, 4, 3, "No More Ideas"],
132   [ 13, 5, 1, "Sad"],
133   [ 14, 5, 2, "Under The Weather"],
134   [ 15, 5, 3, "Suicidal"],
135   [ 16, 1, 1, "The Bees Knees"],
136   [ 17, 1, 2, "Apiary"],
137   [ 18, 1, 3, "Beehind You"],
138 ]);
139
140 $schema->populate('Link', [
141   [ qw/id title/ ],
142   [ 1, 'aaa' ]
143 ]);
144
145 $schema->populate('Bookmark', [
146   [ qw/id link/ ],
147   [ 1, 1 ]
148 ]);
149
150 1;