]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/commitdiff
tests from multicreate
authorzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Tue, 3 Feb 2009 10:34:57 +0000 (10:34 +0000)
committerzby <zby@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
Tue, 3 Feb 2009 10:34:57 +0000 (10:34 +0000)
60 files changed:
lib/DBIx/Class/ResultSet/RecursiveUpdate.pm
t/96multi_create.t [new file with mode: 0644]
t/lib/DBICTest.pm [new file with mode: 0755]
t/lib/DBICTest/ErrorComponent.pm [new file with mode: 0644]
t/lib/DBICTest/FakeComponent.pm [new file with mode: 0644]
t/lib/DBICTest/ForeignComponent.pm [new file with mode: 0644]
t/lib/DBICTest/ForeignComponent/TestComp.pm [new file with mode: 0644]
t/lib/DBICTest/OptionalComponent.pm [new file with mode: 0644]
t/lib/DBICTest/Plain.pm [new file with mode: 0644]
t/lib/DBICTest/Plain/Test.pm [new file with mode: 0644]
t/lib/DBICTest/ResultSetManager.pm [new file with mode: 0644]
t/lib/DBICTest/ResultSetManager/Foo.pm [new file with mode: 0644]
t/lib/DBICTest/Schema.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/.Genre.pm.swp [new file with mode: 0644]
t/lib/DBICTest/Schema/Artist.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/ArtistSourceName.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/ArtistSubclass.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/ArtistUndirectedMap.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Artwork.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Artwork_to_Artist.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Bookmark.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/BooksInLibrary.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/CD.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/CD_to_Producer.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Collection.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/CollectionObject.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Dummy.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Employee.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Event.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/EventTZ.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/FileColumn.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/ForceForeign.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/FourKeys.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Genre.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Image.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/LinerNotes.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Link.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/LyricVersion.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Lyrics.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/NoPrimaryKey.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/NoSuchClass.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/OneKey.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Owners.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Producer.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/SelfRef.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/SelfRefAlias.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/SequenceTest.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Serialized.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Tag.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/Track.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/TreeLike.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/TwoKeyTreeLike.pm [new file with mode: 0644]
t/lib/DBICTest/Schema/TwoKeys.pm [new file with mode: 0755]
t/lib/DBICTest/Schema/TypedObject.pm [new file with mode: 0644]
t/lib/DBICTest/Stats.pm [new file with mode: 0644]
t/lib/DBICTest/SyntaxErrorComponent1.pm [new file with mode: 0644]
t/lib/DBICTest/SyntaxErrorComponent2.pm [new file with mode: 0644]
t/lib/DBICTest/SyntaxErrorComponent3.pm [new file with mode: 0644]
t/var/dvdzbr.db

index 43e8d89561a18d54d4f5a473bfabb94712182698..129407c69f18294dac5812ca8c31f94ce7d1c924 100644 (file)
@@ -29,9 +29,11 @@ sub recursive_update {
     # relations that that should be done after the row is inserted into the database
     # like has_many and might_have
     my %post_updates;
+    my %columns_by_accessor = $self->_get_columns_by_accessor;
+#    warn 'columns_by_accessor: ' . Dumper( \%columns_by_accessor ); use Data::Dumper;
     for my $name ( keys %$updates ){
         my $source = $self->result_source;
-        if( $source->has_column($name) 
+        if( $columns_by_accessor{$name} 
             && !( $source->has_relationship($name) && ref( $updates->{$name} ) ) 
         ){
             $columns{$name} = $updates->{$name};
@@ -61,7 +63,7 @@ sub recursive_update {
     }
     for my $name ( keys %pre_updates ){ 
         my $info = $object->result_source->relationship_info( $name );
-        $self->update_relation( $name, $updates, $object, $info );
+        $self->_update_relation( $name, $updates, $object, $info );
     }
     $self->_delete_empty_auto_increment($object);
 # don't allow insert to recurse to related objects - we do the recursion ourselves
@@ -91,12 +93,24 @@ sub recursive_update {
     }
     for my $name ( keys %post_updates ){ 
         my $info = $object->result_source->relationship_info( $name );
-        $self->update_relation( $name, $updates, $object, $info );
+        $self->_update_relation( $name, $updates, $object, $info );
     }
     return $object;
 }
 
-sub update_relation{
+sub _get_columns_by_accessor {
+    my $self = shift;
+    my $source = $self->result_source;
+    my %columns;
+    for my $name ( $source->columns ){
+        my $info = $source->column_info( $name );
+        $info->{name} = $name;
+        $columns{ $info->{accessor} || $name } = $info;
+    }
+    return %columns;
+}
+
+sub _update_relation{
     my( $self, $name, $updates, $object, $info ) = @_;
 
                     my $related_result = $self->related_resultset( $name )->result_source->resultset;
diff --git a/t/96multi_create.t b/t/96multi_create.t
new file mode 100644 (file)
index 0000000..d1e44b3
--- /dev/null
@@ -0,0 +1,741 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Exception;
+use lib qw(t/lib);
+use DBICTest;
+
+plan tests => 95;
+
+my $schema = DBICTest->init_schema();
+
+diag '* simple create + parent (the stuff $rs belongs_to)';
+eval {
+  my $cd = $schema->resultset('CD')->recursive_update({
+    artist => { 
+      name => 'Fred Bloggs' 
+    },
+    title => 'Some CD',
+    year => 1996
+  });
+
+  isa_ok($cd, 'DBICTest::CD', 'Created CD object');
+  isa_ok($cd->artist, 'DBICTest::Artist', 'Created related Artist');
+  is($cd->artist->name, 'Fred Bloggs', 'Artist created correctly');
+};
+diag $@ if $@;
+
+diag '* same as above but the child and parent have no values, except for an explicit parent pk';
+eval {
+  my $bm_rs = $schema->resultset('Bookmark');
+  my $bookmark = $bm_rs->recursive_update({
+    link => {
+      id => 66,
+    },
+  });
+
+  isa_ok($bookmark, 'DBICTest::Bookmark', 'Created Bookrmark object');
+  isa_ok($bookmark->link, 'DBICTest::Link', 'Created related Link');
+  is (
+    $bm_rs->search (
+      { 'link.title' => $bookmark->link->title },
+      { join => 'link' },
+    )->count,
+    1,
+    'Bookmark and link made it to the DB',
+  );
+};
+diag $@ if $@;
+
+diag '* Create m2m while originating in the linker table';
+eval {
+  my $artist = $schema->resultset('Artist')->first;
+  my $c2p = $schema->resultset('CD_to_Producer')->recursive_update({
+    cd => {
+      artist => $artist,
+      title => 'Bad investment',
+      year => 2008,
+      tracks => [
+        { pos => 1, title => 'Just buy' },
+        { pos => 2, title => 'Why did we do it' },
+        { pos => 3, title => 'Burn baby burn' },
+      ],
+    },
+    producer => {
+      name => 'Lehman Bros.',
+    },
+  });
+
+  isa_ok ($c2p, 'DBICTest::CD_to_Producer', 'Linker object created');
+  my $prod = $schema->resultset ('Producer')->find ({ name => 'Lehman Bros.' });
+  isa_ok ($prod, 'DBICTest::Producer', 'Producer row found');
+  is ($prod->cds->count, 1, 'Producer has one production');
+  my $cd = $prod->cds->first;
+  is ($cd->title, 'Bad investment', 'CD created correctly');
+  is ($cd->tracks->count, 3, 'CD has 3 tracks');
+
+};
+diag $@ if $@;
+
+diag (<<'DG');
+* Create over > 1 levels of might_have with multiple has_many and multiple m2m
+but starting at a has_many level
+
+CD -> has_many -> Tracks -> might have -> Single -> has_many -> Tracks
+                                               \
+                                                \-> has_many \
+                                                              --> CD2Producer
+                                                /-> has_many /
+                                               /
+                                          Producer
+DG
+
+eval {
+  my $artist = $schema->resultset('Artist')->first;
+  my $cd = $schema->resultset('CD')->recursive_update({
+    artist => $artist,
+    title => 'Music to code by at night',
+    year => 2008,
+    tracks => [
+      {
+        pos => 1, # some day me might test this with Ordered
+        title => 'Off by one again',
+      },
+      {
+        pos => 2,
+        title => 'The dereferencer',
+        cd_single => {
+          artist => $artist,
+          year => 2008,
+          title => 'Was that a null (Single)',
+          tracks => [
+            { title => 'The dereferencer', pos => 1 },
+            { title => 'The dereferencer II', pos => 2 },
+          ],
+          cd_to_producer => [
+            {
+              producer => {
+                name => 'K&R',
+              }
+            },
+            {
+              producer => {
+                name => 'Don Knuth',
+              }
+            },
+          ]
+        },
+      },
+    ],
+  });
+
+  isa_ok ($cd, 'DBICTest::CD', 'Main CD object created');
+  is ($cd->title, 'Music to code by at night', 'Correct CD title');
+  is ($cd->tracks->count, 2, 'Two tracks on main CD');
+
+  my ($t1, $t2) = $cd->tracks->all;
+  is ($t1->title, 'Off by one again', 'Correct 1st track name');
+  is ($t1->cd_single, undef, 'No single for 1st track');
+  is ($t2->title, 'The dereferencer', 'Correct 2nd track name');
+  isa_ok ($t2->cd_single, 'DBICTest::CD', 'Created a single for 2nd track');
+
+  my $single = $t2->cd_single;
+  is ($single->tracks->count, 2, 'Two tracks on single CD');
+  is ($single->tracks->find ({ position => 1})->title, 'The dereferencer', 'Correct 1st track title');
+  is ($single->tracks->find ({ position => 2})->title, 'The dereferencer II', 'Correct 2nd track title');
+
+  is ($single->cd_to_producer->count, 2, 'Two producers created for the single cd');
+  is_deeply (
+    [ sort map { $_->producer->name } ($single->cd_to_producer->all) ],
+    ['Don Knuth', 'K&R'],
+    'Producers named correctly',
+  );
+};
+diag $@ if $@;
+
+diag (<<'DG');
+* Same as above but starting at the might_have directly
+
+Track -> might have -> Single -> has_many -> Tracks
+                           \
+                            \-> has_many \
+                                          --> CD2Producer
+                            /-> has_many /
+                           /
+                       Producer
+DG
+
+eval {
+  my $cd = $schema->resultset('CD')->first;
+  my $track = $schema->resultset('Track')->recursive_update({
+    cd => $cd,
+    pos => 77,  # some day me might test this with Ordered
+    title => 'Multicreate rocks',
+    cd_single => {
+      artist => $cd->artist,
+      year => 2008,
+      title => 'Disemboweling MultiCreate',
+      tracks => [
+        { title => 'Why does mst write this way', pos => 1 },
+        { title => 'Chainsaw celebration', pos => 2 },
+        { title => 'Purl cleans up', pos => 3 },
+      ],
+      cd_to_producer => [
+        {
+          producer => {
+            name => 'mst',
+          }
+        },
+        {
+          producer => {
+            name => 'castaway',
+          }
+        },
+        {
+          producer => {
+            name => 'theorbtwo',
+          }
+        },
+      ]
+    },
+  });
+
+  isa_ok ($track, 'DBICTest::Track', 'Main Track object created');
+  is ($track->title, 'Multicreate rocks', 'Correct Track title');
+
+  my $single = $track->cd_single;
+  isa_ok ($single, 'DBICTest::CD', 'Created a single with the track');
+  is ($single->tracks->count, 3, '3 tracks on single CD');
+  is ($single->tracks->find ({ position => 1})->title, 'Why does mst write this way', 'Correct 1st track title');
+  is ($single->tracks->find ({ position => 2})->title, 'Chainsaw celebration', 'Correct 2nd track title');
+  is ($single->tracks->find ({ position => 3})->title, 'Purl cleans up', 'Correct 3rd track title');
+
+  is ($single->cd_to_producer->count, 3, '3 producers created for the single cd');
+  is_deeply (
+    [ sort map { $_->producer->name } ($single->cd_to_producer->all) ],
+    ['castaway', 'mst', 'theorbtwo'],
+    'Producers named correctly',
+  );
+};
+diag $@ if $@;
+
+diag '* Test might_have again but with a PK == FK in the middle (obviously not specified)';
+eval {
+  my $artist = $schema->resultset('Artist')->first;
+  my $cd = $schema->resultset('CD')->recursive_update({
+    artist => $artist,
+    title => 'Music to code by at twilight',
+    year => 2008,
+    artwork => {
+      images => [
+        { name => 'recursive descent' },
+        { name => 'tail packing' },
+      ],
+    },
+  });
+
+  isa_ok ($cd, 'DBICTest::CD', 'Main CD object created');
+  is ($cd->title, 'Music to code by at twilight', 'Correct CD title');
+  isa_ok ($cd->artwork, 'DBICTest::Artwork', 'Artwork created');
+
+  # this test might look weird, but it failed at one point, keep it there
+  my $art_obj = $cd->artwork;
+  ok ($art_obj->has_column_loaded ('cd_id'), 'PK/FK present on artwork object');
+  is ($art_obj->images->count, 2, 'Correct artwork image count via the new object');
+  is_deeply (
+    [ sort $art_obj->images->get_column ('name')->all ],
+    [ 'recursive descent', 'tail packing' ],
+    'Images named correctly in objects',
+  );
+
+  my $artwork = $schema->resultset('Artwork')->search (
+    { 'cd.title' => 'Music to code by at twilight' },
+    { join => 'cd' },
+  )->single;
+
+  is ($artwork->images->count, 2, 'Correct artwork image count via a new search');
+
+  is_deeply (
+    [ sort $artwork->images->get_column ('name')->all ],
+    [ 'recursive descent', 'tail packing' ],
+    'Images named correctly after search',
+  );
+};
+diag $@ if $@;
+
+diag '* Test might_have again but with just a PK and FK (neither specified) in the mid-table';
+eval {
+  my $cd = $schema->resultset('CD')->first;
+  my $track = $schema->resultset ('Track')->recursive_update({
+    cd => $cd,
+    pos => 66,
+    title => 'Black',
+    lyrics => {
+      lyric_versions => [
+        { text => 'The color black' },
+        { text => 'The colour black' },
+      ],
+    },
+  });
+
+  isa_ok ($track, 'DBICTest::Track', 'Main track object created');
+  is ($track->title, 'Black', 'Correct track title');
+  isa_ok ($track->lyrics, 'DBICTest::Lyrics', 'Lyrics created');
+
+  # this test might look weird, but it was failing at one point, keep it there
+  my $lyric_obj = $track->lyrics;
+  ok ($lyric_obj->has_column_loaded ('lyric_id'), 'PK present on lyric object');
+  ok ($lyric_obj->has_column_loaded ('track_id'), 'FK present on lyric object');
+  is ($lyric_obj->lyric_versions->count, 2, 'Correct lyric versions count via the new object');
+  is_deeply (
+    [ sort $lyric_obj->lyric_versions->get_column ('text')->all ],
+    [ 'The color black', 'The colour black' ],
+    'Lyrics text in objects matches',
+  );
+
+
+  my $lyric = $schema->resultset('Lyrics')->search (
+    { 'track.title' => 'Black' },
+    { join => 'track' },
+  )->single;
+
+  is ($lyric->lyric_versions->count, 2, 'Correct lyric versions count via a new search');
+
+  is_deeply (
+    [ sort $lyric->lyric_versions->get_column ('text')->all ],
+    [ 'The color black', 'The colour black' ],
+    'Lyrics text via search matches',
+  );
+};
+diag $@ if $@;
+
+diag (<<'DG');
+* Test a multilevel might-have with a PK == FK in the might_have/has_many table
+
+CD -> might have -> Artwork
+                       \
+                        \-> has_many \
+                                      --> Artwork_to_Artist
+                        /-> has_many /
+                       /
+                     Artist
+DG
+
+eval {
+  my $someartist = $schema->resultset('Artist')->first;
+  my $cd = $schema->resultset('CD')->recursive_update({
+    artist => $someartist,
+    title => 'Music to code by until the cows come home',
+    year => 2008,
+    artwork => {
+      artwork_to_artist => [
+        { artist => { name => 'cowboy joe' } },
+        { artist => { name => 'billy the kid' } },
+      ],
+    },
+  });
+
+  isa_ok ($cd, 'DBICTest::CD', 'Main CD object created');
+  is ($cd->title, 'Music to code by until the cows come home', 'Correct CD title');
+
+  my $art_obj = $cd->artwork;
+  ok ($art_obj->has_column_loaded ('cd_id'), 'PK/FK present on artwork object');
+  is ($art_obj->artists->count, 2, 'Correct artwork creator count via the new object');
+  is_deeply (
+    [ sort $art_obj->artists->get_column ('name')->all ],
+    [ 'billy the kid', 'cowboy joe' ],
+    'Artists named correctly when queried via object',
+  );
+
+  my $artwork = $schema->resultset('Artwork')->search (
+    { 'cd.title' => 'Music to code by until the cows come home' },
+    { join => 'cd' },
+  )->single;
+  is ($artwork->artists->count, 2, 'Correct artwork creator count via a new search');
+  is_deeply (
+    [ sort $artwork->artists->get_column ('name')->all ],
+    [ 'billy the kid', 'cowboy joe' ],
+    'Artists named correctly queried via a new search',
+  );
+};
+diag $@ if $@;
+
+diag '* Nested find_or_create';
+eval {
+  my $newartist2 = $schema->resultset('Artist')->recursive_update({ 
+    name => 'Fred 3',
+    cds => [
+      { 
+        title => 'Noah Act',
+        year => 2007,
+      },
+    ],
+  });
+  is($newartist2->name, 'Fred 3', 'Created new artist with cds via find_or_create');
+};
+diag $@ if $@;
+
+diag '* Multiple same level has_many create';
+eval {
+  my $artist2 = $schema->resultset('Artist')->recursive_update({
+    name => 'Fred 4',
+    cds => [
+      {
+        title => 'Music to code by',
+        year => 2007,
+      },
+    ],
+    cds_unordered => [
+      {
+        title => 'Music to code by 1',
+# original        title => 'Music to code by',
+        year => 2007,
+      },
+    ]
+  });
+
+  is($artist2->in_storage, 1, 'artist with duplicate rels inserted okay');
+};
+diag $@ if $@;
+
+diag '* First create_related pass';
+eval {
+       my $artist = $schema->resultset('Artist')->first;
+       
+       my $cd_result = $schema->resultset('CD')->recursive_update({
+        
+        artist => $artist->artistid,
+               title => 'TestOneCD1',
+               year => 2007,
+               tracks => [
+               
+                       { pos =>111,
+                         title => 'TrackOne',
+                       },
+                       { pos =>112,
+                         title => 'TrackTwo',
+                       }
+               ],
+
+       });
+       
+       ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
+       ok( $cd_result->title eq "TestOneCD1", "Got Expected Title");
+       
+       my $tracks = $cd_result->tracks;
+       
+       ok( $tracks->isa( "DBIx::Class::ResultSet" ), "Got Expected Tracks ResultSet");
+       
+       foreach my $track ($tracks->all)
+       {
+               ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
+       }
+};
+diag $@ if $@;
+
+diag '* second create_related with same arguments';
+eval {
+       my $artist = $schema->resultset('Artist')->first;
+       
+       my $cd_result = $schema->resultset('CD')->recursive_update({
+        
+        artist => $artist->artistid,
+       
+               title => 'TestOneCD2',
+               year => 2007,
+               tracks => [
+               
+                       { pos=>111,
+                         title => 'TrackOne',
+                       },
+                       { pos=>112,
+                         title => 'TrackTwo',
+                       }
+               ],
+
+    liner_notes => { notes => 'I can haz liner notes?' },
+
+       });
+       
+       ok( $cd_result && ref $cd_result eq 'DBICTest::CD', "Got Good CD Class");
+       ok( $cd_result->title eq "TestOneCD2", "Got Expected Title");
+  ok( $cd_result->notes eq 'I can haz liner notes?', 'Liner notes');
+       
+       my $tracks = $cd_result->tracks;
+       
+       ok( $tracks->isa( "DBIx::Class::ResultSet" ), "Got Expected Tracks ResultSet");
+       
+       foreach my $track ($tracks->all)
+       {
+               ok( $track && ref $track eq 'DBICTest::Track', 'Got Expected Track Class');
+       }
+};
+diag $@ if $@;
+
+diag '* create of parents of a record linker table';
+eval {
+  my $cdp = $schema->resultset('CD_to_Producer')->recursive_update({
+    cd => { artist => 1, title => 'foo', year => 2000 },
+    producer => { name => 'jorge' }
+  });
+  ok($cdp, 'join table record created ok');
+};
+diag $@ if $@;
+
+
+diag '* Create foreign key col obj including PK (See test 20 in 66relationships.t)';
+eval {
+  my $new_cd_hashref = { 
+    cdid => 27, 
+    title => 'Boogie Woogie', 
+    year => '2007', 
+    artist => { artistid => 17, name => 'king luke' }
+  };
+
+  my $cd = $schema->resultset("CD")->find(1);
+
+  is($cd->artist->id, 1, 'rel okay');
+
+  my $new_cd = $schema->resultset("CD")->recursive_update($new_cd_hashref);
+  is($new_cd->artist->id, 17, 'new id retained okay');
+};
+diag $@ if $@;
+
+eval {
+       $schema->resultset("CD")->recursive_update({ 
+              cdid => 28, 
+              title => 'Boogie Wiggle', 
+              year => '2007', 
+              artist => { artistid => 18, name => 'larry' }
+             });
+};
+is($@, '', 'new cd created without clash on related artist');
+
+diag '* Test multi create over many_to_many';
+eval {
+  $schema->resultset('CD')->recursive_update({
+    artist => {
+      name => 'larry', # should already exist
+    },
+    title => 'Warble Marble',
+    year => '2009',
+    cd_to_producer => [
+      { producer => { name => 'Cowboy Neal' } },
+    ],
+  });
+
+  my $m2m_cd = $schema->resultset('CD')->search ({ title => 'Warble Marble'});
+  is ($m2m_cd->count, 1, 'One CD row created via M2M create');
+  is ($m2m_cd->first->producers->count, 1, 'CD row created with one producer');
+  is ($m2m_cd->first->producers->first->name, 'Cowboy Neal', 'Correct producer row created');
+};
+
+diag '* And the insane multicreate';
+# (should work, despite the fact that no one will probably use it this way)
+
+# first count how many rows do we initially have
+my $counts;
+$counts->{$_} = $schema->resultset($_)->count for qw/Artist CD Genre Producer Tag/;
+
+# do the crazy create
+eval {
+  my $greatest_collections = $schema->resultset('Genre')->create( { name => '"Greatest" collections' } );
+  my $greatest_collections2 = $schema->resultset('Genre')->create( { name => '"Greatest" collections2' } );
+
+  $schema->resultset('CD')->recursive_update({
+    artist => {
+      name => 'james',
+    },
+    title => 'Greatest hits 1',
+    year => '2012',
+    genre => $greatest_collections,
+    tags => [
+      { tag => 'A' },
+      { tag => 'B' },
+    ],
+    cd_to_producer => [
+      {
+        producer => {
+          name => 'bob',
+          producer_to_cd => [
+            {
+              cd => { 
+                artist => {
+                  name => 'lars',
+                  cds => [
+                    {
+                      title => 'Greatest hits 2',
+                      year => 2012,
+                      genre => $greatest_collections,
+                      tags => [
+                        { tag => 'A' },
+                        { tag => 'B' },
+                      ],
+                      # This cd is created via artist so it doesn't know about producers
+                      cd_to_producer => [
+                        # if we specify 'bob' here things bomb
+                        # as the producer attached to Greatest Hits 1 is
+                        # already created, but not yet inserted.
+                        # Maybe this can be fixed, but things are hairy
+                        # enough already.
+                        #
+                        #{ producer => { name => 'bob' } },
+                        { producer => { name => 'paul' } },
+                        { producer => {
+                          name => 'flemming',
+                          producer_to_cd => [
+                            { cd => {
+                              artist => {
+                                name => 'kirk',
+                                cds => [
+                                  {
+                                    title => 'Greatest hits 3',
+                                    year => 2012,
+                                    genre => $greatest_collections,
+                                    tags => [
+                                      { tag => 'A' },
+                                      { tag => 'B' },
+                                    ],
+                                  },
+                                  {
+                                    title => 'Greatest hits 4',
+                                    year => 2012,
+                                    genre => $greatest_collections2,
+                                    tags => [
+                                      { tag => 'A' },
+                                      { tag => 'B' },
+                                    ],
+                                  },
+                                ],
+                              },
+                              title => 'Greatest hits 5',
+                              year => 2013,
+                              genre => $greatest_collections2,
+                            }},
+                          ],
+                        }},
+                      ],
+                    },
+                  ],
+                },
+                title => 'Greatest hits 6',
+                year => 2012,
+                genre => $greatest_collections,
+                tags => [
+                  { tag => 'A' },
+                  { tag => 'B' },
+                ],
+              },
+            },
+            {
+              cd => { 
+                artist => {
+                  name => 'lars',    
+                  # in recursive_update this creates a new artist - since no id provided
+                  # in original create -
+                  # should already exist
+                  # even though the artist 'name' is not uniquely constrained
+                  # find_or_create will arguably DWIM 
+                },
+                title => 'Greatest hits 7',
+                year => 2013,
+              },
+            },
+          ],
+        },
+      },
+    ],
+  });
+
+  is ($schema->resultset ('Artist')->count, $counts->{Artist} + 4, '4 new artists created');
+  is ($schema->resultset ('Genre')->count, $counts->{Genre} + 2, '2 additional genres created');
+  is ($schema->resultset ('Producer')->count, $counts->{Producer} + 3, '3 new producer');
+  is ($schema->resultset ('CD')->count, $counts->{CD} + 7, '7 new CDs');
+  is ($schema->resultset ('Tag')->count, $counts->{Tag} + 10, '10 new Tags');
+
+  my $cd_rs = $schema->resultset ('CD')
+    ->search ({ title => { -like => 'Greatest hits %' }}, { order_by => 'title'} );
+  is ($cd_rs->count, 7, '7 greatest hits created');
+
+  my $cds_2012 = $cd_rs->search ({ year => 2012});
+  is ($cds_2012->count, 5, '5 CDs created in 2012');
+
+  is (
+    $cds_2012->search(
+      { 'tags.tag' => { -in => [qw/A B/] } },
+      { join => 'tags', group_by => 'me.cdid' }
+    ),
+    5,
+    'All 10 tags were pairwise distributed between 5 year-2012 CDs'
+  );
+
+  my $paul_prod = $cd_rs->search (
+    { 'producer.name' => 'paul'},
+    { join => { cd_to_producer => 'producer' } }
+  );
+  is ($paul_prod->count, 1, 'Paul had 1 production');
+  my $pauls_cd = $paul_prod->single;
+  is ($pauls_cd->cd_to_producer->count, 2, 'Paul had one co-producer');
+  is (
+    $pauls_cd->search_related ('cd_to_producer',
+      { 'producer.name' => 'flemming'},
+      { join => 'producer' }
+    )->count,
+    1,
+    'The second producer is flemming',
+  );
+
+  my $kirk_cds = $cd_rs->search ({ 'artist.name' => 'kirk' }, { join => 'artist' });
+  is ($kirk_cds, 3, 'Kirk had 3 CDs');
+  is (
+    $kirk_cds->search (
+      { 'cd_to_producer.cd' => { '!=', undef } },
+      { join => 'cd_to_producer' },
+    ),
+    1,
+    'Kirk had a producer only on one cd',
+  );
+
+  my $lars_cds = $cd_rs->search ({ 'artist.name' => 'lars' }, { join => 'artist' });
+  is ($lars_cds->count, 3, 'Lars had 3 CDs');
+  is (
+    $lars_cds->search (
+      { 'cd_to_producer.cd' => undef },
+      { join => 'cd_to_producer' },
+    ),
+    0,
+    'Lars always had a producer',
+  );
+  is (
+    $lars_cds->search_related ('cd_to_producer',
+      { 'producer.name' => 'flemming'},
+      { join => 'producer' }
+    )->count,
+    1,
+    'Lars produced 1 CD with flemming',
+  );
+  is (
+    $lars_cds->search_related ('cd_to_producer',
+      { 'producer.name' => 'bob'},
+      { join => 'producer' }
+    )->count,
+    2,
+    'Lars produced 2 CDs with bob',
+  );
+
+  my $bob_prod = $cd_rs->search (
+    { 'producer.name' => 'bob'},
+    { join => { cd_to_producer => 'producer' } }
+  );
+  is ($bob_prod->count, 3, 'Bob produced a total of 3 CDs');
+
+  is (
+    $bob_prod->search ({ 'artist.name' => 'james' }, { join => 'artist' })->count,
+    1,
+    "Bob produced james' only CD",
+  );
+};
+diag $@ if $@;
+
+1;
diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm
new file mode 100755 (executable)
index 0000000..e4b9b76
--- /dev/null
@@ -0,0 +1,325 @@
+package # hide from PAUSE 
+    DBICTest;
+
+use strict;
+use warnings;
+use DBICTest::Schema;
+
+=head1 NAME
+
+DBICTest - Library to be used by DBIx::Class test scripts.
+
+=head1 SYNOPSIS
+
+  use lib qw(t/lib);
+  use DBICTest;
+  use Test::More;
+  
+  my $schema = DBICTest->init_schema();
+
+=head1 DESCRIPTION
+
+This module provides the basic utilities to write tests against 
+DBIx::Class.
+
+=head1 METHODS
+
+=head2 init_schema
+
+  my $schema = DBICTest->init_schema(
+    no_deploy=>1,
+    no_populate=>1,
+    storage_type=>'::DBI::Replicated',
+    storage_type_args=>{
+       balancer_type=>'DBIx::Class::Storage::DBI::Replicated::Balancer::Random'
+    },
+  );
+
+This method removes the test SQLite database in t/var/DBIxClass.db 
+and then creates a new, empty database.
+
+This method will call deploy_schema() by default, unless the 
+no_deploy flag is set.
+
+Also, by default, this method will call populate_schema() by 
+default, unless the no_deploy or no_populate flags are set.
+
+=cut
+
+sub has_custom_dsn {
+       return $ENV{"DBICTEST_DSN"} ? 1:0;
+}
+
+sub _sqlite_dbfilename {
+    return "t/var/DBIxClass.db";
+}
+
+sub _sqlite_dbname {
+    my $self = shift;
+    my %args = @_;
+    return $self->_sqlite_dbfilename if $args{sqlite_use_file} or $ENV{"DBICTEST_SQLITE_USE_FILE"};
+       return ":memory:";
+}
+
+sub _database {
+    my $self = shift;
+    my %args = @_;
+    my $db_file = $self->_sqlite_dbname(%args);
+
+    unlink($db_file) if -e $db_file;
+    unlink($db_file . "-journal") if -e $db_file . "-journal";
+    mkdir("t/var") unless -d "t/var";
+
+    my $dsn = $ENV{"DBICTEST_DSN"} || "dbi:SQLite:${db_file}";
+    my $dbuser = $ENV{"DBICTEST_DBUSER"} || '';
+    my $dbpass = $ENV{"DBICTEST_DBPASS"} || '';
+
+    my @connect_info = ($dsn, $dbuser, $dbpass, { AutoCommit => 1 });
+
+    return @connect_info;
+}
+
+sub init_schema {
+    my $self = shift;
+    my %args = @_;
+
+    my $schema;
+    
+    if ($args{compose_connection}) {
+      $schema = DBICTest::Schema->compose_connection(
+                  'DBICTest', $self->_database(%args)
+                );
+    } else {
+      $schema = DBICTest::Schema->compose_namespace('DBICTest');
+    }
+    if( $args{storage_type}) {
+       $schema->storage_type($args{storage_type});
+    }    
+    if ( !$args{no_connect} ) {
+      $schema = $schema->connect($self->_database(%args));
+      $schema->storage->on_connect_do(['PRAGMA synchronous = OFF'])
+       unless $self->has_custom_dsn;
+    }
+    if ( !$args{no_deploy} ) {
+        __PACKAGE__->deploy_schema( $schema, $args{deploy_args} );
+        __PACKAGE__->populate_schema( $schema )
+         if( !$args{no_populate} );
+    }
+    return $schema;
+}
+
+=head2 deploy_schema
+
+  DBICTest->deploy_schema( $schema );
+
+This method does one of two things to the schema.  It can either call 
+the experimental $schema->deploy() if the DBICTEST_SQLT_DEPLOY environment 
+variable is set, otherwise the default is to read in the t/lib/sqlite.sql 
+file and execute the SQL within. Either way you end up with a fresh set 
+of tables for testing.
+
+=cut
+
+sub deploy_schema {
+    my $self = shift;
+    my $schema = shift;
+    my $args = shift || {};
+
+    if ($ENV{"DBICTEST_SQLT_DEPLOY"}) { 
+        $schema->deploy($args);    
+    } else {
+        open IN, "t/lib/sqlite.sql";
+        my $sql;
+        { local $/ = undef; $sql = <IN>; }
+        close IN;
+        for my $chunk ( split (/;\s*\n+/, $sql) ) {
+          if ( $chunk =~ / ^ (?! --\s* ) \S /xm ) {  # there is some real sql in the chunk - a non-space at the start of the string which is not a comment
+            $schema->storage->dbh->do($chunk) or print "Error on SQL: $chunk\n";
+          }
+        }
+    }
+    return;
+}
+
+=head2 populate_schema
+
+  DBICTest->populate_schema( $schema );
+
+After you deploy your schema you can use this method to populate 
+the tables with test data.
+
+=cut
+
+sub populate_schema {
+    my $self = shift;
+    my $schema = shift;
+
+    $schema->populate('Artist', [
+        [ qw/artistid name/ ],
+        [ 1, 'Caterwauler McCrae' ],
+        [ 2, 'Random Boy Band' ],
+        [ 3, 'We Are Goth' ],
+    ]);
+
+    $schema->populate('CD', [
+        [ qw/cdid artist title year/ ],
+        [ 1, 1, "Spoonful of bees", 1999 ],
+        [ 2, 1, "Forkful of bees", 2001 ],
+        [ 3, 1, "Caterwaulin' Blues", 1997 ],
+        [ 4, 2, "Generic Manufactured Singles", 2001 ],
+        [ 5, 3, "Come Be Depressed With Us", 1998 ],
+    ]);
+
+    $schema->populate('LinerNotes', [
+        [ qw/liner_id notes/ ],
+        [ 2, "Buy Whiskey!" ],
+        [ 4, "Buy Merch!" ],
+        [ 5, "Kill Yourself!" ],
+    ]);
+
+    $schema->populate('Tag', [
+        [ qw/tagid cd tag/ ],
+        [ 1, 1, "Blue" ],
+        [ 2, 2, "Blue" ],
+        [ 3, 3, "Blue" ],
+        [ 4, 5, "Blue" ],
+        [ 5, 2, "Cheesy" ],
+        [ 6, 4, "Cheesy" ],
+        [ 7, 5, "Cheesy" ],
+        [ 8, 2, "Shiny" ],
+        [ 9, 4, "Shiny" ],
+    ]);
+
+    $schema->populate('TwoKeys', [
+        [ qw/artist cd/ ],
+        [ 1, 1 ],
+        [ 1, 2 ],
+        [ 2, 2 ],
+    ]);
+
+    $schema->populate('FourKeys', [
+        [ qw/foo bar hello goodbye sensors/ ],
+        [ 1, 2, 3, 4, 'online' ],
+        [ 5, 4, 3, 6, 'offline' ],
+    ]);
+
+    $schema->populate('OneKey', [
+        [ qw/id artist cd/ ],
+        [ 1, 1, 1 ],
+        [ 2, 1, 2 ],
+        [ 3, 2, 2 ],
+    ]);
+
+    $schema->populate('SelfRef', [
+        [ qw/id name/ ],
+        [ 1, 'First' ],
+        [ 2, 'Second' ],
+    ]);
+
+    $schema->populate('SelfRefAlias', [
+        [ qw/self_ref alias/ ],
+        [ 1, 2 ]
+    ]);
+
+    $schema->populate('ArtistUndirectedMap', [
+        [ qw/id1 id2/ ],
+        [ 1, 2 ]
+    ]);
+
+    $schema->populate('Producer', [
+        [ qw/producerid name/ ],
+        [ 1, 'Matt S Trout' ],
+        [ 2, 'Bob The Builder' ],
+        [ 3, 'Fred The Phenotype' ],
+    ]);
+
+    $schema->populate('CD_to_Producer', [
+        [ qw/cd producer/ ],
+        [ 1, 1 ],
+        [ 1, 2 ],
+        [ 1, 3 ],
+    ]);
+    
+    $schema->populate('TreeLike', [
+        [ qw/id parent name/ ],
+        [ 1, undef, 'root' ],        
+        [ 2, 1, 'foo'  ],
+        [ 3, 2, 'bar'  ],
+        [ 6, 2, 'blop' ],
+        [ 4, 3, 'baz'  ],
+        [ 5, 4, 'quux' ],
+        [ 7, 3, 'fong'  ],
+    ]);
+
+    $schema->populate('Track', [
+        [ qw/trackid cd  position title/ ],
+        [ 4, 2, 1, "Stung with Success"],
+        [ 5, 2, 2, "Stripy"],
+        [ 6, 2, 3, "Sticky Honey"],
+        [ 7, 3, 1, "Yowlin"],
+        [ 8, 3, 2, "Howlin"],
+        [ 9, 3, 3, "Fowlin"],
+        [ 10, 4, 1, "Boring Name"],
+        [ 11, 4, 2, "Boring Song"],
+        [ 12, 4, 3, "No More Ideas"],
+        [ 13, 5, 1, "Sad"],
+        [ 14, 5, 2, "Under The Weather"],
+        [ 15, 5, 3, "Suicidal"],
+        [ 16, 1, 1, "The Bees Knees"],
+        [ 17, 1, 2, "Apiary"],
+        [ 18, 1, 3, "Beehind You"],
+    ]);
+
+    $schema->populate('Event', [
+        [ qw/id starts_at created_on varchar_date varchar_datetime skip_inflation/ ],
+        [ 1, '2006-04-25 22:24:33', '2006-06-22 21:00:05', '2006-07-23', '2006-05-22 19:05:07', '2006-04-21 18:04:06'],
+    ]);
+
+    $schema->populate('Link', [
+        [ qw/id url title/ ],
+        [ 1, '', 'aaa' ]
+    ]);
+
+    $schema->populate('Bookmark', [
+        [ qw/id link/ ],
+        [ 1, 1 ]
+    ]);
+
+    $schema->populate('Collection', [
+        [ qw/collectionid name/ ],
+        [ 1, "Tools" ],
+        [ 2, "Body Parts" ],
+    ]);
+    
+    $schema->populate('TypedObject', [
+        [ qw/objectid type value/ ],
+        [ 1, "pointy", "Awl" ],
+        [ 2, "round", "Bearing" ],
+        [ 3, "pointy", "Knife" ],
+        [ 4, "pointy", "Tooth" ],
+        [ 5, "round", "Head" ],
+    ]);
+    $schema->populate('CollectionObject', [
+        [ qw/collection object/ ],
+        [ 1, 1 ],
+        [ 1, 2 ],
+        [ 1, 3 ],
+        [ 2, 4 ],
+        [ 2, 5 ],
+    ]);
+
+    $schema->populate('Owners', [
+        [ qw/ownerid name/ ],
+        [ 1, "Newton" ],
+        [ 2, "Waltham" ],
+    ]);
+
+    $schema->populate('BooksInLibrary', [
+        [ qw/id owner title source price/ ],
+        [ 1, 1, "Programming Perl", "Library", 23 ],
+        [ 2, 1, "Dynamical Systems", "Library",  37 ],
+        [ 3, 2, "Best Recipe Cookbook", "Library", 65 ],
+    ]);
+}
+
+1;
diff --git a/t/lib/DBICTest/ErrorComponent.pm b/t/lib/DBICTest/ErrorComponent.pm
new file mode 100644 (file)
index 0000000..67f54e8
--- /dev/null
@@ -0,0 +1,8 @@
+#   belongs to t/run/90ensure_class_loaded.tl
+package # hide from PAUSE 
+    DBICTest::ErrorComponent;
+use warnings;
+use strict;
+
+# this is missing on purpose
+# 1;
diff --git a/t/lib/DBICTest/FakeComponent.pm b/t/lib/DBICTest/FakeComponent.pm
new file mode 100644 (file)
index 0000000..fbe21f0
--- /dev/null
@@ -0,0 +1,7 @@
+#   belongs to t/run/90ensure_class_loaded.tl
+package # hide from PAUSE 
+    DBICTest::FakeComponent;
+use warnings;
+use strict;
+
+1;
diff --git a/t/lib/DBICTest/ForeignComponent.pm b/t/lib/DBICTest/ForeignComponent.pm
new file mode 100644 (file)
index 0000000..333dd26
--- /dev/null
@@ -0,0 +1,11 @@
+#   belongs to t/05components.t
+package # hide from PAUSE 
+    DBICTest::ForeignComponent;
+use warnings;
+use strict;
+
+use base qw/ DBIx::Class /;
+
+__PACKAGE__->load_components( qw/ +DBICTest::ForeignComponent::TestComp / );
+
+1;
diff --git a/t/lib/DBICTest/ForeignComponent/TestComp.pm b/t/lib/DBICTest/ForeignComponent/TestComp.pm
new file mode 100644 (file)
index 0000000..cc95940
--- /dev/null
@@ -0,0 +1,9 @@
+#   belongs to t/05components.t
+package # hide from PAUSE
+    DBICTest::ForeignComponent::TestComp;
+use warnings;
+use strict;
+
+sub foreign_test_method { 1 }
+
+1;
diff --git a/t/lib/DBICTest/OptionalComponent.pm b/t/lib/DBICTest/OptionalComponent.pm
new file mode 100644 (file)
index 0000000..5f0d36a
--- /dev/null
@@ -0,0 +1,7 @@
+#   belongs to t/run/90ensure_class_loaded.tl
+package # hide from PAUSE 
+    DBICTest::OptionalComponent;
+use warnings;
+use strict;
+
+1;
diff --git a/t/lib/DBICTest/Plain.pm b/t/lib/DBICTest/Plain.pm
new file mode 100644 (file)
index 0000000..209cc3e
--- /dev/null
@@ -0,0 +1,40 @@
+package # hide from PAUSE 
+    DBICTest::Plain;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Schema/;
+use DBI;
+
+my $db_file = "t/var/Plain.db";
+
+unlink($db_file) if -e $db_file;
+unlink($db_file . "-journal") if -e $db_file . "-journal";
+mkdir("t/var") unless -d "t/var";
+
+my $dsn = "dbi:SQLite:${db_file}";
+
+__PACKAGE__->load_classes("Test");
+my $schema = __PACKAGE__->compose_connection(
+  __PACKAGE__,
+  $dsn,
+  undef,
+  undef,
+  { AutoCommit => 1 }
+);
+
+my $dbh = DBI->connect($dsn);
+
+my $sql = <<EOSQL;
+CREATE TABLE test (
+  id INTEGER NOT NULL,
+  name VARCHAR(32) NOT NULL
+);
+
+INSERT INTO test (id, name) VALUES (1, 'DBIC::Plain is broken!');
+
+EOSQL
+
+$dbh->do($_) for split(/\n\n/, $sql);
+
+1;
diff --git a/t/lib/DBICTest/Plain/Test.pm b/t/lib/DBICTest/Plain/Test.pm
new file mode 100644 (file)
index 0000000..e950278
--- /dev/null
@@ -0,0 +1,18 @@
+package # hide from PAUSE 
+    DBICTest::Plain::Test;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('test');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1
+  },
+  'name' => {
+    data_type => 'varchar',
+  },
+);
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/ResultSetManager.pm b/t/lib/DBICTest/ResultSetManager.pm
new file mode 100644 (file)
index 0000000..08b3159
--- /dev/null
@@ -0,0 +1,7 @@
+package # hide from PAUSE 
+    DBICTest::ResultSetManager;
+use base 'DBIx::Class::Schema';
+
+__PACKAGE__->load_classes("Foo");
+
+1;
diff --git a/t/lib/DBICTest/ResultSetManager/Foo.pm b/t/lib/DBICTest/ResultSetManager/Foo.pm
new file mode 100644 (file)
index 0000000..7253ac1
--- /dev/null
@@ -0,0 +1,10 @@
+package # hide from PAUSE 
+    DBICTest::ResultSetManager::Foo;
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components(qw/ ResultSetManager Core /);
+__PACKAGE__->table('foo');
+
+sub bar : ResultSet { 'good' }
+
+1;
diff --git a/t/lib/DBICTest/Schema.pm b/t/lib/DBICTest/Schema.pm
new file mode 100644 (file)
index 0000000..d683a25
--- /dev/null
@@ -0,0 +1,55 @@
+package # hide from PAUSE
+    DBICTest::Schema;
+
+use base qw/DBIx::Class::Schema/;
+
+no warnings qw/qw/;
+
+__PACKAGE__->load_classes(qw/
+  Artist
+  SequenceTest
+  Employee
+  CD
+  FileColumn
+  Genre
+  Link
+  Bookmark
+  #dummy
+  Track
+  Tag
+  /,
+  { 'DBICTest::Schema' => [qw/
+    LinerNotes
+    Artwork
+    Artwork_to_Artist
+    Image
+    Lyrics
+    LyricVersion
+    OneKey
+    #dummy
+    TwoKeys
+    Serialized
+  /]},
+  (
+    'FourKeys',
+    'FourKeys_to_TwoKeys',
+    '#dummy',
+    'SelfRef',
+    'ArtistUndirectedMap',
+    'ArtistSourceName',
+    'ArtistSubclass',
+    'Producer',
+    'CD_to_Producer',
+  ),
+  qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/,
+  qw/Collection CollectionObject TypedObject Owners BooksInLibrary/,
+  qw/ForceForeign/,
+);
+
+sub sqlt_deploy_hook {
+  my ($self, $sqlt_schema) = @_;
+
+  $sqlt_schema->drop_table('dummy');
+}
+
+1;
diff --git a/t/lib/DBICTest/Schema/.Genre.pm.swp b/t/lib/DBICTest/Schema/.Genre.pm.swp
new file mode 100644 (file)
index 0000000..fedb6a6
Binary files /dev/null and b/t/lib/DBICTest/Schema/.Genre.pm.swp differ
diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm
new file mode 100644 (file)
index 0000000..7f1c789
--- /dev/null
@@ -0,0 +1,79 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Artist;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('artist');
+__PACKAGE__->source_info({
+    "source_info_key_A" => "source_info_value_A",
+    "source_info_key_B" => "source_info_value_B",
+    "source_info_key_C" => "source_info_value_C",
+});
+__PACKAGE__->add_columns(
+  'artistid' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'name' => {
+    data_type => 'varchar',
+    size      => 100,
+    is_nullable => 1,
+  },
+  rank => {
+    data_type => 'integer',
+    default_value => 13,
+  },
+  charfield => {
+    data_type => 'char',
+    size => 10,
+    is_nullable => 1,
+  },
+);
+__PACKAGE__->set_primary_key('artistid');
+
+__PACKAGE__->mk_classdata('field_name_for', {
+    artistid    => 'primary key',
+    name        => 'artist name',
+});
+
+__PACKAGE__->has_many(
+    cds => 'DBICTest::Schema::CD', undef,
+    { order_by => 'year' },
+);
+__PACKAGE__->has_many(
+    cds_unordered => 'DBICTest::Schema::CD'
+);
+
+__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' );
+__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' );
+
+__PACKAGE__->has_many(
+  artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
+  [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
+  { cascade_copy => 0 } # this would *so* not make sense
+);
+
+__PACKAGE__->has_many(
+    artist_to_artwork => 'DBICTest::Schema::Artwork_to_Artist' => 'artist_id'
+);
+__PACKAGE__->many_to_many('artworks', 'artist_to_artwork', 'artwork');
+
+
+sub sqlt_deploy_hook {
+  my ($self, $sqlt_table) = @_;
+
+
+  if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) {
+    $sqlt_table->add_index( name => 'artist_name', fields => ['name'] )
+      or die $sqlt_table->error;
+  }
+}
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Artist::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/ArtistSourceName.pm b/t/lib/DBICTest/Schema/ArtistSourceName.pm
new file mode 100644 (file)
index 0000000..c59bbe5
--- /dev/null
@@ -0,0 +1,8 @@
+package # hide from PAUSE
+    DBICTest::Schema::ArtistSourceName;
+
+use base 'DBICTest::Schema::Artist';
+__PACKAGE__->table(__PACKAGE__->table);
+__PACKAGE__->source_name('SourceNameArtists');
+
+1;
diff --git a/t/lib/DBICTest/Schema/ArtistSubclass.pm b/t/lib/DBICTest/Schema/ArtistSubclass.pm
new file mode 100644 (file)
index 0000000..8dd3f6f
--- /dev/null
@@ -0,0 +1,8 @@
+package # hide from PAUSE
+    DBICTest::Schema::ArtistSubclass;
+
+use base 'DBICTest::Schema::Artist';
+
+__PACKAGE__->table(__PACKAGE__->table);
+
+1;
\ No newline at end of file
diff --git a/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm b/t/lib/DBICTest/Schema/ArtistUndirectedMap.pm
new file mode 100644 (file)
index 0000000..c709572
--- /dev/null
@@ -0,0 +1,20 @@
+package # hide from PAUSE 
+    DBICTest::Schema::ArtistUndirectedMap;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('artist_undirected_map');
+__PACKAGE__->add_columns(
+  'id1' => { data_type => 'integer' },
+  'id2' => { data_type => 'integer' },
+);
+__PACKAGE__->set_primary_key(qw/id1 id2/);
+
+__PACKAGE__->belongs_to( 'artist1', 'DBICTest::Schema::Artist', 'id1', { on_delete => 'RESTRICT', on_update => 'CASCADE'} );
+__PACKAGE__->belongs_to( 'artist2', 'DBICTest::Schema::Artist', 'id2', { on_delete => undef, on_update => 'CASCADE'} );
+__PACKAGE__->has_many(
+  'mapped_artists', 'DBICTest::Schema::Artist',
+  [ {'foreign.artistid' => 'self.id1'}, {'foreign.artistid' => 'self.id2'} ],
+);
+
+1;
diff --git a/t/lib/DBICTest/Schema/Artwork.pm b/t/lib/DBICTest/Schema/Artwork.pm
new file mode 100644 (file)
index 0000000..b6c2cff
--- /dev/null
@@ -0,0 +1,26 @@
+package # hide from PAUSE
+    DBICTest::Schema::Artwork;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('cd_artwork');
+__PACKAGE__->add_columns(
+  'cd_id' => {
+    data_type => 'integer',
+  },
+);
+__PACKAGE__->set_primary_key('cd_id');
+__PACKAGE__->belongs_to('cd', 'DBICTest::Schema::CD', 'cd_id');
+__PACKAGE__->has_many('images', 'DBICTest::Schema::Image', 'artwork_id');
+
+__PACKAGE__->has_many('artwork_to_artist', 'DBICTest::Schema::Artwork_to_Artist', 'artwork_cd_id');
+__PACKAGE__->many_to_many('artists', 'artwork_to_artist', 'artist');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Artwork::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Artwork_to_Artist.pm b/t/lib/DBICTest/Schema/Artwork_to_Artist.pm
new file mode 100644 (file)
index 0000000..da1b4de
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE
+    DBICTest::Schema::Artwork_to_Artist;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('artwork_to_artist');
+__PACKAGE__->add_columns(
+  'artwork_cd_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+  'artist_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+);
+__PACKAGE__->set_primary_key(qw/artwork_cd_id artist_id/);
+__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_cd_id');
+__PACKAGE__->belongs_to('artist', 'DBICTest::Schema::Artist', 'artist_id');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Artwork_to_Artist::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Bookmark.pm b/t/lib/DBICTest/Schema/Bookmark.pm
new file mode 100644 (file)
index 0000000..04e48e6
--- /dev/null
@@ -0,0 +1,32 @@
+package # hide from PAUSE
+    DBICTest::Schema::Bookmark;
+
+    use base 'DBIx::Class::Core';
+
+
+use strict;
+use warnings;
+
+__PACKAGE__->table('bookmark');
+__PACKAGE__->add_columns(
+    'id' => {
+        data_type => 'integer',
+        is_auto_increment => 1
+    },
+    'link' => {
+        data_type => 'integer',
+    },
+);
+
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->belongs_to(link => 'DBICTest::Schema::Link' );
+
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Bookmark::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/BooksInLibrary.pm b/t/lib/DBICTest/Schema/BooksInLibrary.pm
new file mode 100644 (file)
index 0000000..6c2d6aa
--- /dev/null
@@ -0,0 +1,32 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::BooksInLibrary;\r
+\r
+use base qw/DBIx::Class::Core/;\r
+\r
+__PACKAGE__->table('books');\r
+__PACKAGE__->add_columns(\r
+  'id' => {\r
+    data_type => 'integer',\r
+    is_auto_increment => 1,\r
+  },\r
+  'source' => {\r
+    data_type => 'varchar',\r
+    size      => '100',\r
+  },\r
+  'owner' => {\r
+    data_type => 'integer',\r
+  },\r
+  'title' => {\r
+    data_type => 'varchar',\r
+    size      => '100',\r
+  },\r
+  'price' => {\r
+    data_type => 'integer',\r
+    is_nullable => 1,\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key('id');\r
+\r
+__PACKAGE__->resultset_attributes({where => { source => "Library" } });\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/CD.pm b/t/lib/DBICTest/Schema/CD.pm
new file mode 100644 (file)
index 0000000..fcd7202
--- /dev/null
@@ -0,0 +1,86 @@
+package # hide from PAUSE 
+    DBICTest::Schema::CD;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('cd');
+__PACKAGE__->add_columns(
+  'cdid' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'artist' => {
+    data_type => 'integer',
+  },
+  'title' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+  'year' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+  'genreid' => { 
+    data_type => 'integer',
+    is_nullable => 1,
+  },
+  'single_track' => {
+    data_type => 'integer',
+    is_nullable => 1,
+    is_foreign_key => 1,
+  }
+);
+__PACKAGE__->set_primary_key('cdid');
+__PACKAGE__->add_unique_constraint([ qw/artist title/ ]);
+
+__PACKAGE__->belongs_to( artist => 'DBICTest::Schema::Artist', undef, { 
+    is_deferrable => 1, 
+});
+
+# in case this is a single-cd it promotes a track from another cd
+__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track' );
+
+__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
+__PACKAGE__->has_many(
+    tags => 'DBICTest::Schema::Tag', undef,
+    { order_by => 'tag' },
+);
+__PACKAGE__->has_many(
+    cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
+);
+
+__PACKAGE__->might_have(
+    liner_notes => 'DBICTest::Schema::LinerNotes', undef,
+    { proxy => [ qw/notes/ ] },
+);
+__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
+
+__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
+__PACKAGE__->many_to_many(
+    producers_sorted => cd_to_producer => 'producer',
+    { order_by => 'producer.name' },
+);
+
+__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
+    { 'foreign.genreid' => 'self.genreid' },
+    {
+        join_type => 'left',
+        on_delete => 'SET NULL',
+        on_update => 'CASCADE',
+
+    },
+);
+
+#__PACKAGE__->add_relationship('genre', 'DBICTest::Schema::Genre',
+#    { 'foreign.genreid' => 'self.genreid' },
+#    { 'accessor' => 'single' }
+#);
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::CD::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/CD_to_Producer.pm b/t/lib/DBICTest/Schema/CD_to_Producer.pm
new file mode 100644 (file)
index 0000000..8028c7b
--- /dev/null
@@ -0,0 +1,31 @@
+package # hide from PAUSE 
+    DBICTest::Schema::CD_to_Producer;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('cd_to_producer');
+__PACKAGE__->add_columns(
+  cd => { data_type => 'integer' },
+  producer => { data_type => 'integer' },
+);
+__PACKAGE__->set_primary_key(qw/cd producer/);
+
+__PACKAGE__->belongs_to(
+  'cd', 'DBICTest::Schema::CD',
+  { 'foreign.cdid' => 'self.cd' }
+);
+
+__PACKAGE__->belongs_to(
+  'producer', 'DBICTest::Schema::Producer',
+  { 'foreign.producerid' => 'self.producer' },
+  { on_delete => undef, on_update => undef },
+);
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::CD_to_Producer::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Collection.pm b/t/lib/DBICTest/Schema/Collection.pm
new file mode 100644 (file)
index 0000000..1c11dc6
--- /dev/null
@@ -0,0 +1,30 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::Collection;\r
+\r
+use base qw/DBIx::Class::Core/;\r
+\r
+__PACKAGE__->table('collection');\r
+__PACKAGE__->add_columns(\r
+  'collectionid' => {\r
+    data_type => 'integer',\r
+    is_auto_increment => 1,\r
+  },\r
+  'name' => {\r
+    data_type => 'varchar',\r
+    size      => 100,\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key('collectionid');\r
+\r
+__PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject",\r
+                       { "foreign.collection" => "self.collectionid" }\r
+                     );\r
+__PACKAGE__->many_to_many( objects => collection_object => "object" );\r
+__PACKAGE__->many_to_many( pointy_objects => collection_object => "object",\r
+                           { where => { "object.type" => "pointy" } }\r
+                         );\r
+__PACKAGE__->many_to_many( round_objects => collection_object => "object",\r
+                           { where => { "object.type" => "round" } } \r
+                         );\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/CollectionObject.pm b/t/lib/DBICTest/Schema/CollectionObject.pm
new file mode 100644 (file)
index 0000000..d05ae5d
--- /dev/null
@@ -0,0 +1,24 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::CollectionObject;\r
+\r
+use base qw/DBIx::Class::Core/;\r
+\r
+__PACKAGE__->table('collection_object');\r
+__PACKAGE__->add_columns(\r
+  'collection' => {\r
+    data_type => 'integer',\r
+  },\r
+  'object' => {\r
+    data_type => 'integer',\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key(qw/collection object/);\r
+\r
+__PACKAGE__->belongs_to( collection => "DBICTest::Schema::Collection",\r
+                         { "foreign.collectionid" => "self.collection" }\r
+                       );\r
+__PACKAGE__->belongs_to( object => "DBICTest::Schema::TypedObject",\r
+                         { "foreign.objectid" => "self.object" }\r
+                       );\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/Dummy.pm b/t/lib/DBICTest/Schema/Dummy.pm
new file mode 100644 (file)
index 0000000..6bc51d6
--- /dev/null
@@ -0,0 +1,23 @@
+package # hide from PAUSE
+    DBICTest::Schema::Dummy;
+
+use base 'DBIx::Class::Core';
+
+use strict;
+use warnings;
+
+__PACKAGE__->table('dummy');
+__PACKAGE__->add_columns(
+    'id' => {
+        data_type => 'integer',
+        is_auto_increment => 1
+    },
+    'gittery' => {
+        data_type => 'varchar',
+        size      => 100,
+        is_nullable => 1,
+    },
+);
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/Employee.pm b/t/lib/DBICTest/Schema/Employee.pm
new file mode 100644 (file)
index 0000000..7beb833
--- /dev/null
@@ -0,0 +1,45 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Employee;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->load_components(qw( Ordered ));
+
+__PACKAGE__->table('employee');
+
+__PACKAGE__->add_columns(
+    employee_id => {
+        data_type => 'integer',
+        is_auto_increment => 1
+    },
+    position => {
+        data_type => 'integer',
+    },
+    group_id => {
+        data_type => 'integer',
+        is_nullable => 1,
+    },
+    group_id_2 => {
+        data_type => 'integer',
+        is_nullable => 1,
+    },
+    name => {
+        data_type => 'varchar',
+        size      => 100,
+        is_nullable => 1,
+    },
+);
+
+__PACKAGE__->set_primary_key('employee_id');
+__PACKAGE__->position_column('position');
+
+#__PACKAGE__->add_unique_constraint(position_group => [ qw/position group_id/ ]);
+
+__PACKAGE__->mk_classdata('field_name_for', {
+    employee_id => 'primary key',
+    position    => 'list position',
+    group_id    => 'collection column',
+    name        => 'employee name',
+});
+
+1;
diff --git a/t/lib/DBICTest/Schema/Event.pm b/t/lib/DBICTest/Schema/Event.pm
new file mode 100644 (file)
index 0000000..0c02568
--- /dev/null
@@ -0,0 +1,22 @@
+package DBICTest::Schema::Event;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('event');
+
+__PACKAGE__->add_columns(
+  id => { data_type => 'integer', is_auto_increment => 1 },
+  starts_at => { data_type => 'datetime', datetime_undef_if_invalid => 1 },
+  created_on => { data_type => 'timestamp' },
+  varchar_date => { data_type => 'varchar', inflate_date => 1, size => 20, is_nullable => 1 },
+  varchar_datetime => { data_type => 'varchar', inflate_datetime => 1, size => 20, is_nullable => 1 },
+  skip_inflation => { data_type => 'datetime', inflate_datetime => 0, is_nullable => 1 },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/EventTZ.pm b/t/lib/DBICTest/Schema/EventTZ.pm
new file mode 100644 (file)
index 0000000..8445aa1
--- /dev/null
@@ -0,0 +1,19 @@
+package DBICTest::Schema::EventTZ;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('event');
+
+__PACKAGE__->add_columns(
+  id => { data_type => 'integer', is_auto_increment => 1 },
+  starts_at => { data_type => 'datetime', extra => { timezone => "America/Chicago" } },
+  created_on => { data_type => 'timestamp', extra => { timezone => "America/Chicago", floating_tz_ok => 1 } },
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/FileColumn.pm b/t/lib/DBICTest/Schema/FileColumn.pm
new file mode 100644 (file)
index 0000000..cc425ee
--- /dev/null
@@ -0,0 +1,25 @@
+package 
+DBICTest::Schema::FileColumn;
+
+use strict;
+use warnings;
+use base qw/DBIx::Class::Core/;
+use File::Temp qw/tempdir/;
+
+__PACKAGE__->load_components(qw/InflateColumn::File/);
+
+__PACKAGE__->table('file_columns');
+
+__PACKAGE__->add_columns(
+  id => { data_type => 'integer', is_auto_increment => 1 },
+  file => {
+    data_type        => 'varchar',
+    is_file_column   => 1,
+    file_column_path => tempdir(CLEANUP => 1),
+    size             => 255
+  }
+);
+
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/ForceForeign.pm b/t/lib/DBICTest/Schema/ForceForeign.pm
new file mode 100644 (file)
index 0000000..82829b8
--- /dev/null
@@ -0,0 +1,41 @@
+package # hide from PAUSE
+    DBICTest::Schema::ForceForeign;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('forceforeign');
+__PACKAGE__->add_columns(
+  'artist' => { data_type => 'integer' },
+  'cd' => { data_type => 'integer' },
+);
+__PACKAGE__->set_primary_key(qw/artist/);
+
+# Normally this would not appear as a FK constraint
+# since it uses the PK
+__PACKAGE__->might_have(
+                       'artist_1', 'DBICTest::Schema::Artist', {
+                           'foreign.artistid' => 'self.artist',
+                       }, {
+                           is_foreign_key_constraint => 1,
+                       },
+);
+
+# Normally this would appear as a FK constraint
+__PACKAGE__->might_have(
+                       'cd_1', 'DBICTest::Schema::CD', {
+                           'foreign.cdid' => 'self.cd',
+                       }, {
+                           is_foreign_key_constraint => 0,
+                       },
+);
+
+# Normally this would appear as a FK constraint
+__PACKAGE__->belongs_to(
+                       'cd_3', 'DBICTest::Schema::CD', {
+                           'foreign.cdid' => 'self.cd',
+                       }, {
+                           is_foreign_key_constraint => 0,
+                       },
+);
+
+1;
diff --git a/t/lib/DBICTest/Schema/FourKeys.pm b/t/lib/DBICTest/Schema/FourKeys.pm
new file mode 100644 (file)
index 0000000..a1e23db
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE 
+    DBICTest::Schema::FourKeys;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('fourkeys');
+__PACKAGE__->add_columns(
+  'foo' => { data_type => 'integer' },
+  'bar' => { data_type => 'integer' },
+  'hello' => { data_type => 'integer' },
+  'goodbye' => { data_type => 'integer' },
+  'sensors' => { data_type => 'character' },
+);
+__PACKAGE__->set_primary_key(qw/foo bar hello goodbye/);
+
+__PACKAGE__->has_many(
+  'fourkeys_to_twokeys', 'DBICTest::Schema::FourKeys_to_TwoKeys', {
+    'foreign.f_foo' => 'self.foo',
+    'foreign.f_bar' => 'self.bar',
+    'foreign.f_hello' => 'self.hello',
+    'foreign.f_goodbye' => 'self.goodbye',
+});
+
+__PACKAGE__->many_to_many(
+  'twokeys', 'fourkeys_to_twokeys', 'twokeys',
+);
+
+1;
diff --git a/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm b/t/lib/DBICTest/Schema/FourKeys_to_TwoKeys.pm
new file mode 100644 (file)
index 0000000..6e86313
--- /dev/null
@@ -0,0 +1,32 @@
+package # hide from PAUSE 
+    DBICTest::Schema::FourKeys_to_TwoKeys;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('fourkeys_to_twokeys');
+__PACKAGE__->add_columns(
+  'f_foo' => { data_type => 'integer' },
+  'f_bar' => { data_type => 'integer' },
+  'f_hello' => { data_type => 'integer' },
+  'f_goodbye' => { data_type => 'integer' },
+  't_artist' => { data_type => 'integer' },
+  't_cd' => { data_type => 'integer' },
+  'autopilot' => { data_type => 'character' },
+);
+__PACKAGE__->set_primary_key(
+  qw/f_foo f_bar f_hello f_goodbye t_artist t_cd/
+);
+
+__PACKAGE__->belongs_to('fourkeys', 'DBICTest::Schema::FourKeys', {
+  'foreign.foo' => 'self.f_foo',
+  'foreign.bar' => 'self.f_bar',
+  'foreign.hello' => 'self.f_hello',
+  'foreign.goodbye' => 'self.f_goodbye',
+});
+
+__PACKAGE__->belongs_to('twokeys', 'DBICTest::Schema::TwoKeys', {
+  'foreign.artist' => 'self.t_artist',
+  'foreign.cd' => 'self.t_cd',
+});
+
+1;
diff --git a/t/lib/DBICTest/Schema/Genre.pm b/t/lib/DBICTest/Schema/Genre.pm
new file mode 100644 (file)
index 0000000..c1e1167
--- /dev/null
@@ -0,0 +1,30 @@
+package DBICTest::Schema::Genre;
+
+use strict;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('genre');
+__PACKAGE__->add_columns(
+    genreid => {
+      data_type => 'integer',
+      is_auto_increment => 1,
+    },
+    name => {
+      data_type => 'varchar',
+      size => 100,
+    },
+);
+__PACKAGE__->set_primary_key('genreid');
+__PACKAGE__->add_unique_constraint ( genre_name => [qw/name/] );
+
+__PACKAGE__->has_many (cds => 'DBICTest::Schema::CD', 'genreid');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Genre::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Image.pm b/t/lib/DBICTest/Schema/Image.pm
new file mode 100644 (file)
index 0000000..ebfc5bc
--- /dev/null
@@ -0,0 +1,35 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Image;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('images');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'artwork_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+  'name' => {
+    data_type => 'varchar',
+    size => 100,
+  },
+  'data' => {
+    data_type => 'blob',
+    is_nullable => 1,
+  },
+);
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->belongs_to('artwork', 'DBICTest::Schema::Artwork', 'artwork_id');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Image::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/LinerNotes.pm b/t/lib/DBICTest/Schema/LinerNotes.pm
new file mode 100644 (file)
index 0000000..36283e6
--- /dev/null
@@ -0,0 +1,29 @@
+package # hide from PAUSE 
+    DBICTest::Schema::LinerNotes;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('liner_notes');
+__PACKAGE__->add_columns(
+  'liner_id' => {
+    data_type => 'integer',
+  },
+  'notes' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+);
+__PACKAGE__->set_primary_key('liner_id');
+__PACKAGE__->belongs_to(
+  'cd', 'DBICTest::Schema::CD', 'liner_id'
+);
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::LinerNotes::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Link.pm b/t/lib/DBICTest/Schema/Link.pm
new file mode 100644 (file)
index 0000000..d48d4ef
--- /dev/null
@@ -0,0 +1,36 @@
+package # hide from PAUSE
+    DBICTest::Schema::Link;
+
+use base 'DBIx::Class::Core';
+
+use strict;
+use warnings;
+
+__PACKAGE__->table('link');
+__PACKAGE__->add_columns(
+    'id' => {
+        data_type => 'integer',
+        is_auto_increment => 1
+    },
+    'url' => {
+        data_type => 'varchar',
+        size      => 100,
+        is_nullable => 1,
+    },
+    'title' => {
+        data_type => 'varchar',
+        size      => 100,
+        is_nullable => 1,
+    },
+);
+__PACKAGE__->set_primary_key('id');
+
+use overload '""' => sub { shift->url }, fallback=> 1;
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Link::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+1;
diff --git a/t/lib/DBICTest/Schema/LyricVersion.pm b/t/lib/DBICTest/Schema/LyricVersion.pm
new file mode 100644 (file)
index 0000000..9b76193
--- /dev/null
@@ -0,0 +1,31 @@
+package # hide from PAUSE
+    DBICTest::Schema::LyricVersion;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('lyric_versions');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'lyric_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+  'text' => {
+    data_type => 'varchar',
+    size => 100,
+  },
+);
+__PACKAGE__->set_primary_key('id');
+__PACKAGE__->belongs_to('lyric', 'DBICTest::Schema::Lyrics', 'lyric_id');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::LyricVersion::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Lyrics.pm b/t/lib/DBICTest/Schema/Lyrics.pm
new file mode 100644 (file)
index 0000000..e3f629d
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Lyrics;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('lyrics');
+__PACKAGE__->add_columns(
+  'lyric_id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'track_id' => {
+    data_type => 'integer',
+    is_foreign_key => 1,
+  },
+);
+__PACKAGE__->set_primary_key('lyric_id');
+__PACKAGE__->belongs_to('track', 'DBICTest::Schema::Track', 'track_id');
+__PACKAGE__->has_many('lyric_versions', 'DBICTest::Schema::LyricVersion', 'lyric_id');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Lyrics::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/NoPrimaryKey.pm b/t/lib/DBICTest/Schema/NoPrimaryKey.pm
new file mode 100644 (file)
index 0000000..1edda61
--- /dev/null
@@ -0,0 +1,15 @@
+package # hide from PAUSE 
+    DBICTest::Schema::NoPrimaryKey;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('noprimarykey');
+__PACKAGE__->add_columns(
+  'foo' => { data_type => 'integer' },
+  'bar' => { data_type => 'integer' },
+  'baz' => { data_type => 'integer' },
+);
+
+__PACKAGE__->add_unique_constraint(foo_bar => [ qw/foo bar/ ]);
+
+1;
diff --git a/t/lib/DBICTest/Schema/NoSuchClass.pm b/t/lib/DBICTest/Schema/NoSuchClass.pm
new file mode 100644 (file)
index 0000000..2730b3a
--- /dev/null
@@ -0,0 +1,6 @@
+package DBICTest::Schema::NoSuchClass;
+
+## This is purposefully not a real DBIC class
+## Used in t/102load_classes.t
+
+1;
diff --git a/t/lib/DBICTest/Schema/OneKey.pm b/t/lib/DBICTest/Schema/OneKey.pm
new file mode 100644 (file)
index 0000000..63356ac
--- /dev/null
@@ -0,0 +1,22 @@
+package # hide from PAUSE 
+    DBICTest::Schema::OneKey;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('onekey');
+__PACKAGE__->add_columns(
+  'id' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'artist' => {
+    data_type => 'integer',
+  },
+  'cd' => {
+    data_type => 'integer',
+  },
+);
+__PACKAGE__->set_primary_key('id');
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Owners.pm b/t/lib/DBICTest/Schema/Owners.pm
new file mode 100644 (file)
index 0000000..acaf5ed
--- /dev/null
@@ -0,0 +1,21 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::Owners;\r
+\r
+use base qw/DBIx::Class::Core/;\r
+\r
+__PACKAGE__->table('owners');\r
+__PACKAGE__->add_columns(\r
+  'ownerid' => {\r
+    data_type => 'integer',\r
+    is_auto_increment => 1,\r
+  },\r
+  'name' => {\r
+    data_type => 'varchar',\r
+    size      => '100',\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key('ownerid');\r
+\r
+__PACKAGE__->has_many(books => "DBICTest::Schema::BooksInLibrary", "owner");\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/Producer.pm b/t/lib/DBICTest/Schema/Producer.pm
new file mode 100644 (file)
index 0000000..8708eb7
--- /dev/null
@@ -0,0 +1,32 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Producer;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('producer');
+__PACKAGE__->add_columns(
+  'producerid' => {
+    data_type => 'integer',
+    is_auto_increment => 1
+  },
+  'name' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+);
+__PACKAGE__->set_primary_key('producerid');
+__PACKAGE__->add_unique_constraint(prod_name => [ qw/name/ ]);
+
+__PACKAGE__->has_many(
+    producer_to_cd => 'DBICTest::Schema::CD_to_Producer' => 'producer'
+);
+__PACKAGE__->many_to_many('cds', 'producer_to_cd', 'cd');
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Producer::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/SelfRef.pm b/t/lib/DBICTest/Schema/SelfRef.pm
new file mode 100644 (file)
index 0000000..ec715c7
--- /dev/null
@@ -0,0 +1,21 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::SelfRef;\r
+\r
+use base 'DBIx::Class::Core';\r
+\r
+__PACKAGE__->table('self_ref');\r
+__PACKAGE__->add_columns(\r
+  'id' => {\r
+    data_type => 'integer',\r
+    is_auto_increment => 1,\r
+  },\r
+  'name' => {\r
+    data_type => 'varchar',\r
+    size      => 100,\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key('id');\r
+\r
+__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' );\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/SelfRefAlias.pm b/t/lib/DBICTest/Schema/SelfRefAlias.pm
new file mode 100644 (file)
index 0000000..e7ed491
--- /dev/null
@@ -0,0 +1,20 @@
+package # hide from PAUSE \r
+    DBICTest::Schema::SelfRefAlias;\r
+\r
+use base 'DBIx::Class::Core';\r
+\r
+__PACKAGE__->table('self_ref_alias');\r
+__PACKAGE__->add_columns(\r
+  'self_ref' => {\r
+    data_type => 'integer',\r
+  },\r
+  'alias' => {\r
+    data_type => 'integer',\r
+  },\r
+);\r
+__PACKAGE__->set_primary_key(qw/self_ref alias/);\r
+\r
+__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' );\r
+__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' );\r
+\r
+1;\r
diff --git a/t/lib/DBICTest/Schema/SequenceTest.pm b/t/lib/DBICTest/Schema/SequenceTest.pm
new file mode 100644 (file)
index 0000000..bea3f4b
--- /dev/null
@@ -0,0 +1,37 @@
+package # hide from PAUSE 
+    DBICTest::Schema::SequenceTest;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('sequence_test');
+__PACKAGE__->source_info({
+    "source_info_key_A" => "source_info_value_A",
+    "source_info_key_B" => "source_info_value_B",
+    "source_info_key_C" => "source_info_value_C",
+    "source_info_key_D" => "source_info_value_D",
+});
+__PACKAGE__->add_columns(
+  'pkid1' => {
+    data_type => 'integer',
+    auto_nextval => 1,
+    sequence => 'pkid1_seq',
+  },
+  'pkid2' => {
+    data_type => 'integer',
+    auto_nextval => 1,
+    sequence => 'pkid2_seq',
+  },
+  'nonpkid' => {
+    data_type => 'integer',
+    auto_nextval => 1,
+    sequence => 'nonpkid_seq',
+  },
+  'name' => {
+    data_type => 'varchar',
+    size      => 100,
+    is_nullable => 1,
+  },
+);
+__PACKAGE__->set_primary_key('pkid1', 'pkid2');
+
+1;
diff --git a/t/lib/DBICTest/Schema/Serialized.pm b/t/lib/DBICTest/Schema/Serialized.pm
new file mode 100644 (file)
index 0000000..687dcd1
--- /dev/null
@@ -0,0 +1,13 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Serialized;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('serialized');
+__PACKAGE__->add_columns(
+  'id' => { data_type => 'integer' },
+  'serialized' => { data_type => 'text' },
+);
+__PACKAGE__->set_primary_key('id');
+
+1;
diff --git a/t/lib/DBICTest/Schema/Tag.pm b/t/lib/DBICTest/Schema/Tag.pm
new file mode 100644 (file)
index 0000000..0542ae5
--- /dev/null
@@ -0,0 +1,31 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Tag;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('tags');
+__PACKAGE__->add_columns(
+  'tagid' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'cd' => {
+    data_type => 'integer',
+  },
+  'tag' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+);
+__PACKAGE__->set_primary_key('tagid');
+
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Tag::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/Track.pm b/t/lib/DBICTest/Schema/Track.pm
new file mode 100644 (file)
index 0000000..b7b4813
--- /dev/null
@@ -0,0 +1,48 @@
+package # hide from PAUSE 
+    DBICTest::Schema::Track;
+
+use base 'DBIx::Class::Core';
+__PACKAGE__->load_components(qw/InflateColumn::DateTime/);
+
+__PACKAGE__->table('track');
+__PACKAGE__->add_columns(
+  'trackid' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'cd' => {
+    data_type => 'integer',
+  },
+  'position' => {
+    data_type => 'integer',
+    accessor => 'pos',
+  },
+  'title' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+  last_updated_on => {
+    data_type => 'datetime',
+    accessor => 'updated_date',
+    is_nullable => 1
+  },
+);
+__PACKAGE__->set_primary_key('trackid');
+
+__PACKAGE__->add_unique_constraint([ qw/cd position/ ]);
+__PACKAGE__->add_unique_constraint([ qw/cd title/ ]);
+
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
+__PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd');
+
+__PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
+__PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
+
+__PACKAGE__->resultset_class( __PACKAGE__ . '::ResultSet');
+
+package DBICTest::Schema::Track::ResultSet;
+
+use base qw( DBIx::Class::ResultSet::RecursiveUpdate );
+
+
+1;
diff --git a/t/lib/DBICTest/Schema/TreeLike.pm b/t/lib/DBICTest/Schema/TreeLike.pm
new file mode 100644 (file)
index 0000000..365571d
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE 
+    DBICTest::Schema::TreeLike;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('treelike');
+__PACKAGE__->add_columns(
+  'id' => { data_type => 'integer', is_auto_increment => 1 },
+  'parent' => { data_type => 'integer' , is_nullable=>1},
+  'name' => { data_type => 'varchar',
+    size      => 100,
+ },
+);
+__PACKAGE__->set_primary_key(qw/id/);
+__PACKAGE__->belongs_to('parent', 'TreeLike',
+                          { 'foreign.id' => 'self.parent' });
+__PACKAGE__->has_many('children', 'TreeLike', { 'foreign.parent' => 'self.id' });
+
+## since this is a self referential table we need to do a post deploy hook and get
+## some data in while constraints are off
+
+ sub sqlt_deploy_hook {
+   my ($self, $sqlt_table) = @_;
+
+   ## We don't seem to need this anymore, but keeping it for the moment
+   ## $sqlt_table->add_index(name => 'idx_name', fields => ['name']);
+ }
+1;
diff --git a/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm b/t/lib/DBICTest/Schema/TwoKeyTreeLike.pm
new file mode 100644 (file)
index 0000000..89d8e0a
--- /dev/null
@@ -0,0 +1,21 @@
+package # hide from PAUSE 
+    DBICTest::Schema::TwoKeyTreeLike;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('twokeytreelike');
+__PACKAGE__->add_columns(
+  'id1' => { data_type => 'integer' },
+  'id2' => { data_type => 'integer' },
+  'parent1' => { data_type => 'integer' },
+  'parent2' => { data_type => 'integer' },
+  'name' => { data_type => 'varchar',
+    size      => 100,
+ },
+);
+__PACKAGE__->set_primary_key(qw/id1 id2/);
+__PACKAGE__->add_unique_constraint('tktlnameunique' => ['name']);
+__PACKAGE__->belongs_to('parent', 'DBICTest::Schema::TwoKeyTreeLike',
+                          { 'foreign.id1' => 'self.parent1', 'foreign.id2' => 'self.parent2'});
+
+1;
diff --git a/t/lib/DBICTest/Schema/TwoKeys.pm b/t/lib/DBICTest/Schema/TwoKeys.pm
new file mode 100755 (executable)
index 0000000..69af2e6
--- /dev/null
@@ -0,0 +1,30 @@
+package # hide from PAUSE
+    DBICTest::Schema::TwoKeys;
+
+use base 'DBIx::Class::Core';
+
+__PACKAGE__->table('twokeys');
+__PACKAGE__->add_columns(
+  'artist' => { data_type => 'integer' },
+  'cd' => { data_type => 'integer' },
+);
+__PACKAGE__->set_primary_key(qw/artist cd/);
+
+__PACKAGE__->belongs_to(
+    artist => 'DBICTest::Schema::Artist',
+    {'foreign.artistid'=>'self.artist'},
+);
+
+__PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD', undef, { is_deferrable => 0, add_fk_index => 0 } );
+
+__PACKAGE__->has_many(
+  'fourkeys_to_twokeys', 'DBICTest::Schema::FourKeys_to_TwoKeys', {
+    'foreign.t_artist' => 'self.artist',
+    'foreign.t_cd' => 'self.cd',
+});
+
+__PACKAGE__->many_to_many(
+  'fourkeys', 'fourkeys_to_twokeys', 'fourkeys',
+);
+
+1;
diff --git a/t/lib/DBICTest/Schema/TypedObject.pm b/t/lib/DBICTest/Schema/TypedObject.pm
new file mode 100644 (file)
index 0000000..6498add
--- /dev/null
@@ -0,0 +1,28 @@
+package # hide from PAUSE 
+    DBICTest::Schema::TypedObject;
+
+use base qw/DBIx::Class::Core/;
+
+__PACKAGE__->table('typed_object');
+__PACKAGE__->add_columns(
+  'objectid' => {
+    data_type => 'integer',
+    is_auto_increment => 1,
+  },
+  'type' => {
+    data_type => 'varchar',
+    size      => '100',
+  },
+  'value' => {
+    data_type => 'varchar',
+    size      => 100,
+  },
+);
+__PACKAGE__->set_primary_key('objectid');
+
+__PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject",
+                       { "foreign.object" => "self.objectid" }
+                     );
+__PACKAGE__->many_to_many( collections => collection_object => "collection" );
+
+1;
diff --git a/t/lib/DBICTest/Stats.pm b/t/lib/DBICTest/Stats.pm
new file mode 100644 (file)
index 0000000..5a4544f
--- /dev/null
@@ -0,0 +1,63 @@
+package DBICTest::Stats;
+use strict;
+use warnings;
+
+use base qw/DBIx::Class::Storage::Statistics/;
+
+sub txn_begin {
+  my $self = shift;
+
+  $self->{'TXN_BEGIN'}++;
+  return $self->{'TXN_BEGIN'};
+}
+
+sub txn_rollback {
+  my $self = shift;
+
+  $self->{'TXN_ROLLBACK'}++;
+  return $self->{'TXN_ROLLBACK'};
+}
+
+sub txn_commit {
+  my $self = shift;
+
+  $self->{'TXN_COMMIT'}++;
+  return $self->{'TXN_COMMIT'};
+}
+
+sub svp_begin {
+  my ($self, $name) = @_;
+
+  $self->{'SVP_BEGIN'}++;
+  return $self->{'SVP_BEGIN'};
+}
+
+sub svp_release {
+  my ($self, $name) = @_;
+
+  $self->{'SVP_RELEASE'}++;
+  return $self->{'SVP_RELEASE'};
+}
+
+sub svp_rollback {
+  my ($self, $name) = @_;
+
+  $self->{'SVP_ROLLBACK'}++;
+  return $self->{'SVP_ROLLBACK'};
+}
+
+sub query_start {
+  my ($self, $string, @bind) = @_;
+
+  $self->{'QUERY_START'}++;
+  return $self->{'QUERY_START'};
+}
+
+sub query_end {
+  my ($self, $string) = @_;
+
+  $self->{'QUERY_END'}++;
+  return $self->{'QUERY_START'};
+}
+
+1;
diff --git a/t/lib/DBICTest/SyntaxErrorComponent1.pm b/t/lib/DBICTest/SyntaxErrorComponent1.pm
new file mode 100644 (file)
index 0000000..3fb5045
--- /dev/null
@@ -0,0 +1,9 @@
+#   belongs to t/run/90ensure_class_loaded.tl
+package # hide from PAUSE 
+    DBICTest::SyntaxErrorComponent1;
+use warnings;
+use strict;
+
+my $str ''; # syntax error
+
+1;
diff --git a/t/lib/DBICTest/SyntaxErrorComponent2.pm b/t/lib/DBICTest/SyntaxErrorComponent2.pm
new file mode 100644 (file)
index 0000000..ac6cfb8
--- /dev/null
@@ -0,0 +1,9 @@
+#   belongs to t/run/90ensure_class_loaded.tl
+package # hide from PAUSE 
+    DBICTest::SyntaxErrorComponent2;
+use warnings;
+use strict;
+
+my $str ''; # syntax error
+
+1;
diff --git a/t/lib/DBICTest/SyntaxErrorComponent3.pm b/t/lib/DBICTest/SyntaxErrorComponent3.pm
new file mode 100644 (file)
index 0000000..34f3c3f
--- /dev/null
@@ -0,0 +1,5 @@
+package DBICErrorTest::SyntaxError;
+
+use strict;
+
+I'm a syntax error!
index 7abee9a67327f7af92c264b441c705aeea51fa8d..74ed9a4ef991732eb8996f4c9323e817ba5e56dc 100644 (file)
Binary files a/t/var/dvdzbr.db and b/t/var/dvdzbr.db differ
This page took 0.094266 seconds and 4 git commands to generate.