Commit | Line | Data |
f812ef60 |
1 | package make_dbictest_db_clashing_monikers; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use DBI; |
6 | |
7 | eval { require DBD::SQLite }; |
8 | my $class = $@ ? 'SQLite2' : 'SQLite'; |
9 | |
10 | my $fn = './t/dbictest_clashing_tables.db'; |
11 | |
12 | unlink($fn); |
13 | our $dsn = "dbi:$class:dbname=$fn"; |
14 | my $dbh = DBI->connect($dsn); |
15 | |
16 | $dbh->do($_) for ( |
17 | q|CREATE TABLE foo ( |
18 | fooid INTEGER PRIMARY KEY, |
19 | footext TEXT DEFAULT 'footext', |
20 | foodt TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
21 | )|, |
22 | q|CREATE TABLE bar ( |
23 | barid INTEGER PRIMARY KEY, |
24 | fooref INTEGER REFERENCES foo(fooid) |
25 | )|, |
26 | # this will cause a singularized moniker clash |
27 | q|CREATE TABLE bars ( |
28 | barid INTEGER PRIMARY KEY, |
29 | fooref INTEGER REFERENCES foo(fooid) |
30 | )|, |
31 | q|INSERT INTO foo (fooid, footext) VALUES (1,'Foo text for number 1')|, |
32 | q|INSERT INTO foo (fooid, footext) VALUES (2,'Foo record associated with the Bar with barid 3')|, |
33 | q|INSERT INTO foo (fooid, footext) VALUES (3,'Foo text for number 3')|, |
34 | q|INSERT INTO foo (fooid, footext) VALUES (4,'Foo text for number 4')|, |
35 | q|INSERT INTO bar VALUES (1,4)|, |
36 | q|INSERT INTO bar VALUES (2,3)|, |
37 | q|INSERT INTO bar VALUES (3,2)|, |
38 | q|INSERT INTO bar VALUES (4,1)|, |
39 | ); |
40 | |
41 | END { unlink($fn); } |
42 | |
43 | 1; |