[dev] [Tickets #10880] Rdo drops objects from result when eager relation target is NULL or invalid key

Ralf Lang lang at b1-systems.de
Mon Feb 20 15:19:44 UTC 2012


>> I've been thinking about this for a while now. The lazy relation thing
>> is fixed: Accessing a to-one-relation where the reference key is
>> invalid (does not exist) now throws Rdo Exception, accessing a
>> reference key of NULL returns null instead of the first possible object.
>>
>> I have no clear strategy to fix eager relations:
>> As my test cases show, Objects which reference either NULL keys or
>> invalid keys will simply not be loaded from database although they exist.
>>
>> An idea would be to use the lazy loading code but execute it
>> immediately (will be slower than join for larger data sets).
>> Is there a portable Sql which says "take result of join result table
>> but add distinct keys from another sql statement"?
>>
> Why don't we do a LEFT JOIN with a WHERE clause instead of an INNER JOIN
> for ? I haven't checked this performance-wise but at least we would not
> lose LHS items which have no valid RHS items this way.
>
> I really like Horde_Rdo and I used it for paid work. In fact I am using
> it now and experience its limits. I've created a branch Horde_Rdo_Fixes:
>
> My Idea:
>
> * Base Items should always be returned by a search, ignoring if (eager)
> related items are found (currently non-matching eager relations make
> missing result lines)
> * Wrong references (relation keys) should always throw exceptions if
> explicitly asked for but silently turned to null or (no result line)
> otherwise (in ->save() and the likes)
> * void references (relation keys) should not throw an exception but
> either null (to one relation) or a list without the missing item (to
> many relation).
>
> I'll do this as time permits or objectives require but any 2nd pair of
> eyes is welcome as well as critizism of my understanding what Rdo should
> do.
>

I've been re-thinking this. To-Many-Relations always return a 
Horde_Rdo_List object over which you can savely iterate even if it's empty.

To-One-relations are often used in longer chains

$baby->mother->granny->granny_age;

At least I would do it this way in perl, with eval() and supplying an 
exception object reference in the die() scalar - roughly the same as an 
exception in php.

In php, I get a php fatal when I access a method on a null response. I 
cannot catch this.

If the mother->granny relation is empty, I would like to get an 
exception. I have to check for failure either way. But with an 
exception, I only have one try()/catch() instead of two levels of if 
(!($related = $object->relation)) { continue; }

Now that we have the Horde 5 BC break opportunity, I think it would be 
more useful to go the exception route.

What do you think?

Does this affect existing Horde llc apps?

-- 
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang at b1-systems.de

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537


More information about the dev mailing list