Skip to content

Commit

Permalink
Examples and documentation update and cleanup
Browse files Browse the repository at this point in the history
This version updates the original POD with slightly more information
so that more DBIx::Class functionality is revealed.  The source code is
removed from POD, and instead the reader is directed to the examples
directory.

It also changes the example schema from silly auto-inferred column
names to proper *id-suffixed ones.
  • Loading branch information
talexb authored and ribasushi committed Mar 20, 2015
1 parent b7fcdab commit 1f9ae1a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 339 deletions.
2 changes: 1 addition & 1 deletion Changes
Expand Up @@ -28,7 +28,7 @@ Revision history for DBIx::Class

* Misc
- Remove warning about potential side effects of RT#79576 (scheduled)
- Various doc improvements (GH#62, GH#66, GH#70, GH#71, GH#72)
- Various doc improvements (GH#35, GH#62, GH#66, GH#70, GH#71, GH#72)
- Skip tests in a way more intelligent and speedy manner when optional
dependencies are missing
- Make the Optional::Dependencies error messages cpanm-friendly
Expand Down
2 changes: 1 addition & 1 deletion examples/Schema/MyApp/Schema/Result/Artist.pm
Expand Up @@ -21,7 +21,7 @@ __PACKAGE__->set_primary_key('artistid');

__PACKAGE__->add_unique_constraint([qw( name )]);

__PACKAGE__->has_many('cds' => 'MyApp::Schema::Result::Cd');
__PACKAGE__->has_many('cds' => 'MyApp::Schema::Result::Cd', 'artistid');

1;

8 changes: 4 additions & 4 deletions examples/Schema/MyApp/Schema/Result/Cd.pm
Expand Up @@ -12,7 +12,7 @@ __PACKAGE__->add_columns(
data_type => 'integer',
is_auto_increment => 1
},
artist => {
artistid => {
data_type => 'integer',
},
title => {
Expand All @@ -26,9 +26,9 @@ __PACKAGE__->add_columns(

__PACKAGE__->set_primary_key('cdid');

__PACKAGE__->add_unique_constraint([qw( title artist )]);
__PACKAGE__->add_unique_constraint([qw( title artistid )]);

__PACKAGE__->belongs_to('artist' => 'MyApp::Schema::Result::Artist');
__PACKAGE__->has_many('tracks' => 'MyApp::Schema::Result::Track');
__PACKAGE__->belongs_to('artist' => 'MyApp::Schema::Result::Artist', 'artistid');
__PACKAGE__->has_many('tracks' => 'MyApp::Schema::Result::Track', 'cdid');

1;
6 changes: 3 additions & 3 deletions examples/Schema/MyApp/Schema/Result/Track.pm
Expand Up @@ -12,7 +12,7 @@ __PACKAGE__->add_columns(
data_type => 'integer',
is_auto_increment => 1
},
cd => {
cdid => {
data_type => 'integer',
},
title => {
Expand All @@ -22,8 +22,8 @@ __PACKAGE__->add_columns(

__PACKAGE__->set_primary_key('trackid');

__PACKAGE__->add_unique_constraint([qw( title cd )]);
__PACKAGE__->add_unique_constraint([qw( title cdid )]);

__PACKAGE__->belongs_to('cd' => 'MyApp::Schema::Result::Cd');
__PACKAGE__->belongs_to('cd' => 'MyApp::Schema::Result::Cd', 'cdid');

1;
4 changes: 2 additions & 2 deletions examples/Schema/insertdb.pl
Expand Up @@ -31,7 +31,7 @@
}

$schema->populate('Cd', [
[qw/title artist/],
[qw/title artistid/],
@cds,
]);

Expand All @@ -55,6 +55,6 @@
}

$schema->populate('Track',[
[qw/cd title/],
[qw/cdid title/],
@tracks,
]);
9 changes: 5 additions & 4 deletions examples/Schema/testdb.pl
Expand Up @@ -53,7 +53,8 @@ sub get_tracks_by_artist {
}
);
while (my $track = $rs->next) {
print $track->title . "\n";
print $track->title . " (from the CD '" . $track->cd->title
. "')\n";
}
print "\n";
}
Expand All @@ -70,7 +71,7 @@ sub get_cd_by_track {
}
);
my $cd = $rs->first;
print $cd->title . "\n\n";
print $cd->title . " has the track '$tracktitle'.\n\n";
}

sub get_cds_by_artist {
Expand Down Expand Up @@ -104,7 +105,7 @@ sub get_artist_by_track {
}
);
my $artist = $rs->first;
print $artist->name . "\n\n";
print $artist->name . " recorded the track '$tracktitle'.\n\n";
}

sub get_artist_by_cd {
Expand All @@ -119,5 +120,5 @@ sub get_artist_by_cd {
}
);
my $artist = $rs->first;
print $artist->name . "\n\n";
print $artist->name . " recorded the CD '$cdtitle'.\n\n";
}

0 comments on commit 1f9ae1a

Please sign in to comment.