Hi,
I was wondering if anyone could offer some insight into a problem I'm
finding. I wish to create a relationship using a left join by this doesn't
appear to be happening when I trace the SQL. My only thought is that it is
something to do with using a 'table' without a primary key or whose
On Tue, Jun 18, 2013 at 11:54 AM, Stephen Shorrock
stephen.shorr...@gmail.com wrote:
snip
then (in Cat app)
$c-model('MyApp::IndexStatus')-search_related('old_statuses');
produces SQL something like:
SELECT me.myindex, me.myoldindex, me.mystatus FROM index_statuses me JOIN
index_statuses
That's going to generate a whole bunch of queries (1 per row), unless you
include it in a prefetch attribute to the first call:
foreach my $index_status
($c-model('MyApp::IndexStatus')-search(undef,{prefetch='old_statuses'})) {
# Generate the HTML here with columns from $index_status...
Thanks Robert.
I've attempted to extract the relevant relationship from my code, though
when i use it i intend to group by and test for a not exists via matching a
null row with the left join. I really need to have a left join in this
relationship. It appears to be working for other has_many
On Tue, Jun 18, 2013 at 12:58 PM, Stephen Shorrock
stephen.shorr...@gmail.com wrote:
Thanks Robert.
I've attempted to extract the relevant relationship from my code, though
when i use it i intend to group by and test for a not exists via matching a
null row with the left join. I really
That is indeed my plan! I admittedly haven't tried a manual join perhaps as
I was under the impression search related did the same thing. Though
thinking about it now search_related will attempt to return the related
objects thus not left joining and it it quite possibly the source of my
I think Robert has cracked it, but why prefetch?
On Jun 18, 2013 7:14 PM, Francisco Obispo fobi...@isc.org wrote:
Again,
I think you want to use 'prefetch'.
On Jun 18, 2013, at 11:09 AM, Robert Wohlfarth rbwohlfa...@gmail.com
wrote:
Ah, well then I answered the wrong question :)
Again,
I think you want to use 'prefetch'.
On Jun 18, 2013, at 11:09 AM, Robert Wohlfarth rbwohlfa...@gmail.com wrote:
Ah, well then I answered the wrong question :)
How about this code?
$c-model('MyApp::IndexStatus')-search({'old_statuses.id' =
undef},{join='old_statuses'})
Prefetch is really smart, and in the newer versions of DBIx::Class is even
capable of taking multiple relations without the risk of duplicating rows.
http://search.cpan.org/~frew/DBIx-Class-0.08205/lib/DBIx/Class/ResultSet.pm#prefetch
Basically as I understood the problem, you want to fetch