[Bast-commits] r5636 - in DBIx-Class/0.08/branches/bugfix_28451/t:
. bugfixes lib/DBICTest/Schema lib/DBICTest/Schema/28451
robkinyon at dev.catalyst.perl.org
robkinyon at dev.catalyst.perl.org
Tue Feb 24 17:45:04 GMT 2009
Author: robkinyon
Date: 2009-02-24 17:45:04 +0000 (Tue, 24 Feb 2009)
New Revision: 5636
Added:
DBIx-Class/0.08/branches/bugfix_28451/t/bugfixes/
DBIx-Class/0.08/branches/bugfix_28451/t/bugfixes/rt28451.t
DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/
DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Account.pm
DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Group.pm
DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Person.pm
Log:
Added code to reproduce problem
Added: DBIx-Class/0.08/branches/bugfix_28451/t/bugfixes/rt28451.t
===================================================================
--- DBIx-Class/0.08/branches/bugfix_28451/t/bugfixes/rt28451.t (rev 0)
+++ DBIx-Class/0.08/branches/bugfix_28451/t/bugfixes/rt28451.t 2009-02-24 17:45:04 UTC (rev 5636)
@@ -0,0 +1,61 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema(
+ no_populate => 1,
+);
+$schema->storage()->debug( 1 );
+
+$schema->populate('DBICTest::Schema::28451::Account', [
+ [ qw/account_id username person_id/ ],
+ [ 1, 'barney', 3 ],
+ [ 2, 'fred', 1 ],
+]);
+
+$schema->populate('DBICTest::Schema::28451::Group', [
+ [ qw/account_id username person_id/ ],
+ [ 1, 'foo', 1 ],
+ [ 2, 'bar', 2 ],
+ [ 3, 'baz', undef ],
+]);
+
+$schema->populate('DBICTest::Schema::28451::Peron', [
+ [ qw/account_id username person_id/ ],
+ [ 1, 'Fred', 1 ],
+ [ 2, 'Wilma', 1 ],
+ [ 3, 'Barney', 2 ],
+]);
+
+plan tests => 1;
+
+my $rs = $schema->resultset('Group')->search(
+ undef,
+ {
+ '+select' => [ { COUNT => 'members.person_id' } ],
+ '+as' => [ qw/ member_count / ],
+ join => [ 'members' ],
+ group_by => [ qw/ me.group_id / ],
+ },
+);
+warn ${$rs->as_query}->[0], $/;
+
+$rs = $rs->search(
+ undef,
+ {
+ prefetch => { account => 'person' },
+ },
+);
+warn ${$rs->as_query}->[0], $/;
+
+foreach ( $rs->all() ) {
+ print "name: " . $_->name() . "\n";
+ print "owner: " . $_->account()->person()->first_name() . "\n";
+ print "members: " . $_->member_count() . "\n";
+ print "\n";
+}
Added: DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Account.pm
===================================================================
--- DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Account.pm (rev 0)
+++ DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Account.pm 2009-02-24 17:45:04 UTC (rev 5636)
@@ -0,0 +1,17 @@
+package # hide from PAUSE
+ DBICTest::Schema::28451::Account;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components( qw/ Core PK::Auto / );
+__PACKAGE__->table( '28451_accounts' );
+__PACKAGE__->add_columns( qw/ account_id username person_id / );
+__PACKAGE__->set_primary_key( qw/ account_id / );
+
+__PACKAGE__->belongs_to( person => 'DBICTest::Schema::28451::Person', 'person_id' );
+__PACKAGE__->has_many( administered_groups => 'DBICTest::Schema::28451::Group', 'account_id' );
+
+1;
Added: DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Group.pm
===================================================================
--- DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Group.pm (rev 0)
+++ DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Group.pm 2009-02-24 17:45:04 UTC (rev 5636)
@@ -0,0 +1,20 @@
+package # hide from PAUSE
+ DBICTest::Schema::28451::Group;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components( qw/ Core PK::Auto / );
+__PACKAGE__->table( '28451_groups' );
+__PACKAGE__->add_columns( qw/ group_id name account_id / );
+__PACKAGE__->set_primary_key( qw/ group_id / );
+
+__PACKAGE__->mk_group_accessors( column => 'member_count' );
+
+__PACKAGE__->belongs_to( account => 'DBICTest::Schema::28451::Account', 'account_id' );
+#__PACKAGE__->has_many( person => 'DBICTest::Schema::28451::Person', 'group_id' );
+__PACKAGE__->has_many( members => 'DBICTest::Schema::28451::Person', 'group_id' );
+
+1;
Added: DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Person.pm
===================================================================
--- DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Person.pm (rev 0)
+++ DBIx-Class/0.08/branches/bugfix_28451/t/lib/DBICTest/Schema/28451/Person.pm 2009-02-24 17:45:04 UTC (rev 5636)
@@ -0,0 +1,16 @@
+package # hide from PAUSE
+ DBICTest::Schema::28451::Person;
+
+use strict;
+use warnings;
+
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components( qw/ Core PK::Auto / );
+__PACKAGE__->table( '28451_people' );
+__PACKAGE__->add_columns( qw/ person_id first_name group_id / );
+__PACKAGE__->set_primary_key( qw/ person_id / );
+
+__PACKAGE__->belongs_to( 'group', 'DBICTest::Schema::28451::Group', 'group_id' );
+
+1;
More information about the Bast-commits
mailing list