[Dbix-class] How to use DBIx::Class on a view
Matt S Trout
dbix-class at trout.me.uk
Tue Nov 15 21:06:03 CET 2005
On Tue, Nov 15, 2005 at 05:31:29PM +0000, Nigel Metheringham wrote:
> I would like to use DBIx::Class to access a view of a table -
> specifically its a GROUP of a JOIN to aggregate a batch of per-user data
> into a group summary (I'll post the actual SQL below so you can see what
> I mean).
>
> This view has no primary key, which may confuse things.
>
> The SQLite (test database - will shortly go PostgresQL) code for the
> view is:-
> CREATE VIEW group_date_feature_map AS
> SELECT date,
> bs_group,
> feature,
> count(*) AS count
> FROM user_date_feature_map
> JOIN bs_user
> ON user_date_feature_map.bs_user = bs_user.id
> GROUP BY date, bs_group, feature;
I reckon your primary key is (date,bs_group,feature).
That's certainly what I was intending to default the PK facility on
GROUP BY resultsets in DBIx::Class to when I get time to write them.
--
Matt S Trout Specialists in Perl consulting, web development, and
Technical Director UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Dbix-class
mailing list