On 10/6/05, Uwe Voelker <[EMAIL PROTECTED]> wrote: > Currently RDBO allows only one table/relation via require_objects.
I don't recall why I had that constraint in there, but I'm pretty sure there was a good reason. I'll look into it. > In my application I would need one 1:N and a prefetch (via > with_objects/require_objects). Right now I can leave the prefetch out, but if > the query ever gets complexer (more 1:N relation to be searched) I'm out. To do that, you can use with_objects instead of require_objects. That will cause an outer join for some kinds of relationships, but it shouldn't matter to a smart database because you'll have the query conditions constraining things. All that leaves is the "distinct" issue and the fact that you only want to fetch certain columns. > The DISTINCT is to avoid double objects, if an product has two prices in > a region 'DE' Well, you won't actual get any doubles in your return value, of course, but yes, redundant data will be fetched behind the scenes. To solve that, I'm thinking of adding something like this: $p = Product::Manager->get_products( distinct => [ 't1' ], require_objects => [ 'prices' ], query => [ 't2.region' => 'DE' ]) which would produce SQL like this: SELECT DISTINCT t1.* FROM products t1 LEFT JOIN prices t2 ON (t1.id = t2.product_id) WHERE t2.region = 'DE' or it could be an outer join, depending on how prices is related to products. Either way, the results should be the same. Possible values for the "distinct" param would be: * True scalar value: distinct => 1 # DISTINCT t1.* * List of table names or aliases distinct => [ 't1', 't3' ] # DISTINCT t1.*, t3.* What do you think? -John ------------------------------------------------------- This SF.Net email is sponsored by: Power Architecture Resource Center: Free content, downloads, discussions, and more. http://solutions.newsforge.com/ibmarch.tmpl _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object