[Dbix-class] Twiddling SELECT lists and WHERE clauses

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Sep 12 13:27:54 GMT 2011


On Mon, Sep 12, 2011 at 01:56:09AM -0700, dorian taylor wrote:
> Thanks Peter, I'll try my best:
> 
> I want to create a pivot table (matrix, spreadsheet, whatever) using
> an aggregate. The aggregate function is different depending on what I
> want in the table cells (e.g. count the primary key, but sum and avg
> for certain quantitative values). The data come from three different
> tables which represent a normalized depiction of a set of records,
> i.e. the primary keys are the same for each but they don't necessarily
> match up perfectly.
> 
> Anyway, the pivot table itself isn't the problem, but rather is
> translating the parameters (Catalyst path args, natch) that select the
> correct table to start from. Consider:
> 
> /function/datum/y-axis/x-axis?filter=foo
> 
> The function is the aggregate function (e.g. count, sum), the datum is
> the column to be aggregated, y-axis is which (db) column value to put
> into the rows, x-axis is which to make the columns (think
> Data::Table::pivot). The filter keys correspond to columns/expressions
> in the WHERE clause.
> 
> So the problem is that the datum may not always be in the same table,
> which means there is no guarantee that the columns referred to by
> either the axes or the filter will be ambiguous, collide, or even be
> resolvable.
> 
> So what (it seems like) I need to be able to do is know which tables
> the columns (referred to by the axes and the filter) are in so I can
> properly qualify them.

You are explaining me why you want to do something, but are not telling
me what is it exactly you want to do. Show the code where you need to
determine the table alias.





More information about the DBIx-Class mailing list