Created
August 4, 2016 19:25
-
-
Save simonecesano/50da29e94de4301bba789ed1bbdfa7ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
package Mare::Schema::Result::SummaryTHing; | |
use strict; | |
use warnings; | |
use base 'DBIx::Class::Core'; | |
__PACKAGE__->table_class('DBIx::Class::ResultSource::View'); | |
__PACKAGE__->table('summary_thing'); | |
__PACKAGE__->result_source_instance->is_virtual(1); | |
my $sql = <<'SQL'; | |
select foo.thing as thing, | |
group_concat(distinct foo.bar) as bars, | |
count(*) as results | |
from foo | |
join gongs_bar on gongs_foo.yak = foo.yak | |
left join yak_hair on yak_hair.some_field = gongs_foo.some_field | |
group by foo.thing | |
SQL | |
; | |
__PACKAGE__->add_columns( | |
"thing", | |
{ data_type => "varchar", is_nullable => 1, size => 32 }, | |
"bars", | |
{ data_type => "varchar", is_nullable => 1, size => 256 }, | |
"results", | |
{ data_type => "integer" }, | |
); | |
__PACKAGE__->result_source_instance->view_definition($sql); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment