On Fri, Jul 28, 2006 at 12:20:54PM +0100, Ash Berlin wrote:
> mock wrote:
> > Yeah, looks like I'm going to have to do the from hackery.
> >
> > So I tried the stupidly obvious:
> >
> > my $rs = $schema->resultset('Getcourses')->search(undef,
> > {
> >     from => 'getcourses(\'STUDENT\')',
> > })->first;
> >
> > print "Name ",$rs->name, "\n";
> >
> > Which gives me this error:
> >
> > DBD::Pg::st execute failed: ERROR:  missing FROM-clause entry for table "me"
> > DBIx::Class::ResultSet::first(): Error executing 'SELECT me.courseid, 
> > me.name, me.seattotal, me.seatleft, me.slot, me.priority, me.availid, 
> > me.begindate, me.enddate, me.couponname, me.coupontype, me.coupontotal, 
> > me.couponleft, me.price, me.tax, me.currency FROM getcourses('STUDENT')' 
> > (): ERROR:  missing FROM-clause entry for table "me"
> >
> > On first inspection it looks like it is doing what I want 
> > "SELECT * FROM getcourses('STUDENT')"
> > but I don't understand the error message.  The documentation talks a lot 
> > about
> > custom joins, but that doesn't look like what I'm trying to do.  Any hints?
> >
> > mock
> >   
> It is expecting:
> 
>   SELECT ... FROM getcourses('STUDENT') me
> 
> but the "me" (table alias) is missing.
> 
> Try:
> 
>   from => 'getcourses(\'STUDENT\') me',
> 
> Not sure if there is a proper way of doing that or not tho
> 
> -ash
>

my $rs = $schema->resultset('Getcourses')->search(undef,
{
  from => 'getcourses(\'STUDENT\') me',
})->first;
print "Name ",$rs->name, "\n";


works!!!!
I owe you a beer.  If you're going to YAPC::EU please collect from me.

thanks
mock
 

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to