4 use dbixcsl_common_tests;
6 eval { require DBD::SQLite };
7 my $class = $@ ? 'SQLite2' : 'SQLite';
9 my $tester = dbixcsl_common_tests->new(
11 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT',
12 dsn => "dbi:$class:dbname=./t/sqlite_test",
17 # 'sqlite_' is reserved, so we use 'extra_'
19 CREATE TABLE "extra_loader_test1" (
20 "id" NOT NULL PRIMARY KEY,
21 "value" TEXT UNIQUE NOT NULL
25 CREATE TABLE extra_loader_test2 (
26 event_id INTEGER PRIMARY KEY
30 CREATE TABLE extra_loader_test3 (
31 person_id INTEGER PRIMARY KEY
34 # Wordy, newline-heavy SQL to stress the regexes
36 CREATE TABLE extra_loader_test4 (
37 event_id INTEGER NOT NULL
38 CONSTRAINT fk_event_id
39 REFERENCES extra_loader_test2(event_id),
40 person_id INTEGER NOT NULL
41 CONSTRAINT fk_person_id
42 REFERENCES extra_loader_test3 (person_id),
43 PRIMARY KEY (event_id, person_id)
47 drop => [ qw/extra_loader_test1 extra_loader_test2 extra_loader_test3 extra_loader_test4 / ],
50 my ($schema, $monikers, $classes) = @_;
52 ok ((my $rs = $schema->resultset($monikers->{extra_loader_test1})),
53 'resultset for quoted table');
55 ok ((my $source = $rs->result_source), 'source');
57 is_deeply [ $source->columns ], [ qw/id value/ ],
58 'retrieved quoted column names from quoted table';
60 ok ((exists $source->column_info('value')->{is_nullable}),
61 'is_nullable exists');
63 is $source->column_info('value')->{is_nullable}, 0,
64 'is_nullable is set correctly';
66 ok (($source = $schema->source($monikers->{extra_loader_test4})),
69 is_deeply [ $source->primary_columns ], [ qw/event_id person_id/ ],
70 'composite primary key';
72 is ($source->relationships, 2,
73 '2 foreign key constraints found');
82 unlink './t/sqlite_test';