[Dbix-class] Custom SQL

Gordon Irving goraxe at goraxe.me.uk
Mon Dec 14 16:53:46 GMT 2009

On Mon, Dec 14, 2009 at 05:30:45PM +0100, Bernhard Graf wrote:
> Gordon Irving schrieb:
> > Where I have done this in the past
> > I have used DBIx::Class::ResultSource::View as the parent, and then load core
> > via load_components (in many cases it seems you need to load core last),  then 
> > set the __PACKAGE__->table_class, set a __PACKAGE->table to use as the
> > source name.  I think you also need to set a __PACKAGE__->result_class to set how the
> > returned results should be blessed.
> > 
> > HTH
> No. Not at all.
> You say parent is DBIx::Class::ResultSource::View, and then you set
> __PACKAGE__->table_class ... to what?

Okay some code I know works

package My::Schema::GroupSearch

use strict;
use warnings;

use base qw/DBIx::Class/; #okay so I didn't parent to ::View, different
module, sorry





      groups me
      name like ?
      groups me
      join historyevents on historyevents.group_id = me.id and historyevents.event_type in (1,2,3,4,5,11,12,14)
      join eventtype on historyevents.event_type = eventtype.id
      filecount > 0
      and short_description in ('usercomment', 'toolcomment')
      and match (comments) against (?)

> When I set a table, the error message becomes:
>   Can't locate object method "is_virtual" via package
>   "DBIx::Class::ResultSource::Table" at My/Schema/Result/MyRequest.pm
>   line 12.
> It really frustrates me, when simple things become that difficult.
> Bernhard Graf

What version of DBIx::Class are you using, have you made sure you actually have 
DBIx::Class::ResultSource::View?  Yep setting this up is a little tricky I had to 
go a few rounds of asking in #dbix-class to get it working, but it does work and makes
 sense in the end.

If you are still having problems please include your version of DBIx::Class and the
 full code that is throwing an error.

> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

More information about the DBIx-Class mailing list