[Dbix-class] Static / reference data
Andy Armstrong
andy at hexten.net
Wed Aug 22 20:18:08 GMT 2018
On 22 Aug 2018, at 21:10, Peter Mottram <peter at sysnix.com> wrote:
>
> On 22/08/18 22:03, Andy Armstrong wrote:
>> On 22 Aug 2018, at 20:55, Matthew Somerville <matthew at mysociety.org> wrote:
>>> On 22 August 2018 at 20:22, Andy Armstrong <andy at 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.
>
> Sounds like the join type might be wrong for the 'parent' relationship.
> You can add:
>
> join_type => 'LEFT'
>
> https://metacpan.org/pod/DBIx::Class::Relationship::Base#join_type
Brilliant - thanks Peter - that's got it.
Really impressive how well that works.
Thanks all.
--
Andy Armstrong, Hexten
More information about the DBIx-Class
mailing list