On 22 Aug 2018, at 20:55, Matthew Somerville <matt...@mysociety.org> wrote:
> 
> On 22 August 2018 at 20:22, Andy Armstrong <a...@hexten.net> wrote:
>> If I do prefetch => ['service', { service => 'parent' }] I only get results 
>> for the cases where the service hierarchy is two levels deep.
> 
> I think you might only want prefetch => { service => 'parent' } ?
> The "The "prefetch" attribute can be used with any of the relationship
> types" bit of the documentation seems relevant here, it sounds like
> there's no reason why it wouldn't work, as long as it knows the parent
> is optional (might_have). Like "liner_notes" in the example.


That seems to generate a query that limits the results to only those services 
that have multiple levels - which is understandable.

I'm now contemplating whether the services really need to be hierarchical. It's 
an awkward fit for a single query regardless of whether I use DBIC and only 
works in the current implementation because the whole services table is loaded 
once and converted at that point into a shallow tree.

Thanks all :)

-- 
Andy Armstrong, Hexten




_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to