allow undef for has_many rels in addition to empty arrayref + tests
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / t / lib / DBSchema.pm
1 package DBSchema;
2
3 # Created by DBIx::Class::Schema::Loader v0.03000 @ 2006-10-02 08:24:09
4
5 use strict;
6 use warnings;
7
8 use base 'DBIx::Class::Schema';
9 use DateTime;
10
11 __PACKAGE__->load_namespaces( default_resultset_class => '+DBIx::Class::ResultSet::RecursiveUpdate' );
12
13 sub tables_exist {
14 my ( $dsn, $user, $pass ) = @_;
15 my $dbh = DBI->connect($dsn, $user, $pass, );
16 return $dbh->tables( '%', '%', 'dvd', );
17 }
18
19
20 sub get_test_schema {
21 my ( $dsn, $user, $pass ) = @_;
22 $dsn ||= 'dbi:SQLite:dbname=t/var/dvdzbr.db';
23 warn "testing $dsn\n";
24 my $schema = __PACKAGE__->connect( $dsn, $user, $pass, {} );
25 my $deploy_attrs;
26 $deploy_attrs->{add_drop_table} = 1 if tables_exist( $dsn, $user, $pass );
27 $schema->deploy( $deploy_attrs );
28 $schema->populate('Personality', [
29 [ qw/user_id / ],
30 [ '1'],
31 [ '2' ],
32 [ '3'],
33 ]
34 );
35 $schema->populate('User', [
36 [ qw/username name password / ],
37 [ 'jgda', 'Jonas Alves', ''],
38 [ 'isa' , 'Isa', '', ],
39 [ 'zby' , 'Zbyszek Lukasiak', ''],
40 ]
41 );
42 $schema->populate('Tag', [
43 [ qw/name file / ],
44 [ 'comedy', '' ],
45 [ 'dramat', '' ],
46 [ 'australian', '' ],
47 ]
48 );
49 $schema->populate('Dvd', [
50 [ qw/name imdb_id owner current_borrower creation_date alter_date / ],
51 [ 'Picnick under the Hanging Rock', 123, 1, 3, '2003-01-16 23:12:01', undef ],
52 [ 'The Deerhunter', 1234, 1, 1, undef, undef ],
53 [ 'Rejs', 1235, 3, 1, undef, undef ],
54 [ 'Seksmisja', 1236, 3, 1, undef, undef ],
55 ]
56 );
57 $schema->populate( 'Dvdtag', [
58 [ qw/ dvd tag / ],
59 [ 1, 2 ],
60 [ 1, 3 ],
61 [ 3, 1 ],
62 [ 4, 1 ],
63 ]
64 );
65 return $schema;
66 }
67
68
69 1;
70
This page took 0.036403 seconds and 4 git commands to generate.