use base 'DBIx::Class'; __PACKAGE__->load_components("Core"); __PACKAGE__->table("Locations"); __PACKAGE__->add_columns( "locationid", { data_type => "integer", is_nullable => 0, size => undef }, "name", { data_type => "string", is_nullable => 0, size => undef }, ); __PACKAGE__->set_primary_key("locationid"); __PACKAGE__->has_many( "npcs", "fhl::Schema::Npcs", { "foreign.locationid" => "self.locationid" }, ); __PACKAGE__->has_many( "incidents", "fhl::Schema::Incidents", { "foreign.locationid" => "self.locationid" }, ); ... my $source = __PACKAGE__->result_source_instance(); my $new_source = $source->new($source); $new_source->source_name( 'DB::Locations::NumberActiveIncidents' ); $new_source->name( \< ? GROUP BY l.locationid ORDER BY NumIncidents DESC ) SQL fhl::Schema->register_source( 'DB::Locations::NumberActiveIncidents' => $new_source ); #### my $active = [ $schema->resultset('Locations::NumberActiveIncidents')->search( {}, { bind => [ $now ] } )]; #### my $active = [$schema->resultset('Incidents::Active')->search({}, { bind => [ $now ] } )]; foreach my $incident (@$active) { print $incident->description, " ", $incident->locationid->name, "\n"; } #### Use of uninitialized value in subroutine entry at c:/Perl/site/lib/DBIx/Class/Storage/DBI.pm line 1003. DBIx::Class::InflateColumn::get_inflated_column(): DBI Exception: DBD::SQLite::db prepare_cached failed: unrecognized token: "0x2270f9c"(1) at dbdimp.c line 271 [for Statement "INSERT INTO SCALAR(0x2270f9c) (locationid) VALUES (?)"] at (eval 970) line 6 #### fhl::Schema->register_source( 'DB::Locations::NumberActiveIncidents' => $new_source );