• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Qualifier involving many-to-many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Qualifier involving many-to-many relationship


  • Subject: Re: Qualifier involving many-to-many relationship
  • From: Paul Hoadley <email@hidden>
  • Date: Thu, 29 Jan 2015 15:06:49 +1030

On 29 Jan 2015, at 2:52 pm, Paul Hoadley <email@hidden> wrote:

So, here’s my recommendation:

1) Make your “Connection” entity have a single integer primary key. Do not have a compound PK.

Is a compound PK going to prevent ERXExistsQualifier working in a case like this?  I can make the change, just wondering why.

Ah, OK: it won't prevent ERXExistsQualifier working until I try to force it to generate an IN subquery in the SQL, at which point there are too many columns in the SELECT.

2) Use ERXExistsQualifier.

It should do the trick :-)

I'm trying... can you push me along a little bit based on the desired SQL above?

I think I got it.  This is what I wanted:

SELECT t0.id, t0.id_no, t0.user_id FROM teacher t0 WHERE NOT EXISTS (SELECT 1 FROM connection e0 WHERE e0.teacher_id = t0.id AND e0.school_id = 1);

And this:

ERXQ.not(new ERXExistsQualifier(Connection.SCHOOL.is(this), Teacher.CONNECTIONS_KEY))

generates this:

SELECT t0.id, t0.id_no, t0.user_id FROM teacher t0 WHERE not ( EXISTS ( SELECT exists0.school_id, exists0.teacher_id FROM connection exists0 WHERE exists0.school_id = 1 AND exists0.teacher_id = t0.id ) );

Looks good to me.  Thanks Aaron.


-- 
Paul Hoadley
http://logicsquad.net/


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Qualifier involving many-to-many relationship (From: Paul Hoadley <email@hidden>)
 >Re: Qualifier involving many-to-many relationship (From: Aaron Rosenzweig <email@hidden>)
 >Re: Qualifier involving many-to-many relationship (From: Paul Hoadley <email@hidden>)

  • Prev by Date: Re: Qualifier involving many-to-many relationship
  • Next by Date: limiting popupbutton list with a fetchSpec
  • Previous by thread: Re: Qualifier involving many-to-many relationship
  • Next by thread: limiting popupbutton list with a fetchSpec
  • Index(es):
    • Date
    • Thread