Re: qualifier with (NULL or joined value)?
Re: qualifier with (NULL or joined value)?
- Subject: Re: qualifier with (NULL or joined value)?
- From: Chuck Hill <email@hidden>
- Date: Tue, 26 Apr 2016 17:23:06 +0000
- Thread-topic: qualifier with (NULL or joined value)?
It is a database thing, you need to model the relationship as an outer join.
Chuck
On 2016-04-26, 9:45 AM, "webobjects-dev-bounces+chill=email@hidden on behalf of OC" <webobjects-dev-bounces+chill=email@hidden on behalf of email@hidden> wrote:
>Hi there,
>
>I would need to fetch objects with qualifier
>
>===
>EOQualifier.qualifierWithQualifierFormat("owner.userType = %@ OR owner = NULL",new NSArray(pc.userType))
>===
>
>where "owner" is a :1 relationship based on C_OWNER_ID foreign key. That, alas, does not work at all. It generates a SQL
>
>===
>SELECT ... FROM "T_COMPETENCE" t0, "T_USER" T1 WHERE (t0."C_OWNER_ID" is NULL OR T1."C_USER_TYPE" = 9) AND t0."C_OWNER_ID" = T1."C_UID"
>===
>
>which never returns any row whose "owner"/C_OWNER_ID is NULL, for the latter part of WHERE (AND t0."C_OWNER_ID" = T1."C_UID") prevents it.
>
>Is this a WebObjects bug or a database bug?
>
>Is there a way to write directly a qualifier which would work properly, i.e., same way as my extremely ugly work-around code of
>
>===
>def all=new NSMutableArray()
>def nulls=... fetch with q-format ... "owner = NULL"
>if (nulls) all.addObjectsFromArray(nulls)
>def types=... fetch with q-format ... "owner.userType = %@",pc.userType
>if (types) all.addObjectsFromArray(types)
>return all
>===
>
>does?
>
>Thanks,
>OC
>
>
> _______________________________________________
>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
_______________________________________________
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