First, what is the "arbitrary-depth joins" feature?  It's the ability of the
Manager to auto-join more that two tables away (the current limit).  Here's
an example:

* Each product has one vendor
* Each vendor has many addresses
* Each address has one state

Task: In a single query, get all Products with their vendors, the vendors'
addresses, and the state for each address.

In the current RDBO, this is not possible.  You could get products with
their vendors:

    $products = 
      Product::Manager->get_products(require_objects => [ 'vendor' ]);

    print $products->[0]->vendor->name; # does not hit the db

but then you'd have to hit the db again to get anything "deeper", e.g. the
vendor's addresses:

    @addrs = $products->[0]->vendor->addresses; # hits the db

With the new "arbitrary-depth joins" feature, you can join as deep as you'd
like.  The syntax I'm using for this feature right now is a chain of
relationship names, with "." between each one.  Example:

    $products = 
      Product::Manager->get_products(
        require_objects => [ 'vendor.addresses.state' ]);

    print $products->[0]->vendor->name;         # does not hit the db
    @addrs = $products->[0]->vendor->addresses; # does not hit the db
    print $addrs[0]->state->postal_code;        # does not hit the db

I'm pretty happy with that syntax, but I've also been considering the use of
"arrows" like this:

    $products = 
      Product::Manager->get_products(
        require_objects => [ 'vendor->addresses->state' ]);

That's more typing, but it might be a bit better at conveying the link
relationship.  Then again, it also has more visual noise.

So, anyone have any opinions, or a suggestion of an alternative syntax?

(no, I'm not going to make it configurable ;)
-John




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to