my $loader = Class::DBI::Loader->new(
dsn => "dbi:SQLite:dbname=ORMTest.db",
#options => { RaiseError => 1, AutoCommit => 0, TraceLevel => 1},
options => { RaiseError => 1, AutoCommit => 0},
namespace => "Footy",
);
Footy::Games->has_a(round => 'Footy::Rounds') ;
Footy::Rounds->has_many(games => 'Footy::Games') ;
Footy::Games->has_a(home_team => 'Footy::Teams') ;
Footy::Games->has_a(away_team => 'Footy::Teams') ;
(The relationships don't load correctly via Class::DBI::Loader for
SQLite, so I set them up manually).
I then try to retrieve all of the games for a round via the round
has_many games relationship.
my $iter = Footy::Rounds->retrieve(1)->games ;
while (my $game = $iter->next) {
print $game->game,"\t" ;
print $game->home_team->name,"\t" ;
print $game->away_team->name,"\t" ;
print $game->venue,"\n" ;
}
This generates the right number of rows, but the data is wrong:
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
1 Richmond Carlton MCG
I expected to see the data for all 8 games, not the first game repeated
8 times.
I then add all of the columns to the Essential group by adding the
following statement to the setup code before trying to retrieve the
rows:
Footy::Games->columns(Essential => Footy::Games->columns) ;
I then get the result I expected:
1 Richmond Carlton MCG
2 Geelong Essendon MCG
3 Melbourne Hawthorn MCG
4 Sydney St Kilda ANZ
5 Brisbane Lions West Coast Gabba
6 Port Adelaide North Melbourne AAMI
7 Western Bulldogs Collingwood Etihad
8 Fremantle Adelaide Subiaco
Any ideas why I have to do this ? Is this a bug ?