I have three classes.  User, Group, and GroupMembership.  GM is a mapping class
between User and Group.  (I will have additional data on it in the future.)

I do this:

  my $user  = User->new( ... )->create;
  my $group = Group->new( ... )->create;

  @g = $user->groups;

  is(@g, 0); # passes

  $user->add_groups({ ... });

So now I should have that user in that group...

  @g = $user->groups;

  is(@g, 1); # passes

  @u = $group->users;

  is(@u, 1); # fails, but that seems reasonable

  $group->load;

  @u = $group->users;
  is(@u, 0); # fails, which is a little less reasonable

Okay, at this point I looked at the docs and decided to try using "with"

  $group->load(with => 'groups');

  @u = $group->users;
  is(@u, 1); # hooray!

...except when I was about to cheer about this on IRC, I noticed that I'd said
"with => 'groups'" and there *is* no "groups" relationship.  I had meant to
write "with => 'users'" but flubbed.  It seems like even this works:

  $group->load(with => 1);

Huh!

(I later realized that I wanted [ 'users' ] anyway, but... well, this was just
weird.)

-- 
rjbs

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to