On 5/3/06, Michael Lackhoff <[EMAIL PROTECTED]> wrote:
    groups => {
        type      => 'many to many',
        map_class => 'Groupmappings',
    },

but how can I negate this, so I get all the groups, the user is not a
member of?

You're going to have to do a Manager query (wrapped in a method, if
you like).  What you're asking for doesn't fit within the relationship
model as defined by the bundled relationship methods and behaviors.

Sure, on "get" you can run the desired query to get the list of
groups.  But on "set"...well what does that mean?  Does that mean to
take the user out of all these groups?  Or add this group to the list
of all groups, but don't put this user in it? (Put no one in it?) Adding to or setting a negated set is not something that RDBO's
default relationship methods handle.

There's no reason you can't add a customized relationship type with
different methods (perhaps even just inheriting from the defaults and
removing the ability to "set") but it's certainly less work (and just
as clear, IMO) to wrap the appropriate Manager call in a (get-only)
method.

Or should I use the get_groups() manager method:
my $not_in_groups = Groups->get_groups(
    clauses => ["not exists (select * from groupmappings where
user_id = $userid and group_id = id)"],
);

Yeah, basically (although there are other ways to formulate that query
that maynot require hard-coded SQL clauses, depending on your db).

-John


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to