[Dbix-class] trouble with using 'select' in a search clause

John Napiorkowski jjn1056 at yahoo.com
Wed May 17 10:47:36 CEST 2006


Hi,

I'm trying to create a query to perform something like
this:

SELECT me.*, invitees.* 
  FROM members_invitees me  
  JOIN invitees invitees 
  ON ( invitees.invitee_id = me.invitee_id ) 
WHERE ( member_id = 1 );

Now I have a DBIx class that defined two tables, one
called "members_invitees" and another called
"invitees".  These tables look like this:

invitees
  invitee_id (PK)
  email

members_invitees
  member_id (PK, FK to table 'members')
  invitee_id (PK, FK to table 'invitees')
  status (FK to table 'status')

So the table "members_invitees" is a many to many
table between "members" and "invitees".

According to the documentation I can append columns to
the select statement.  Using the example given I
created a query (this is using Catalyst but should
show my meaning):

my $rs = $c->model("db::members_invitees")->search(
		
  {
    member_id => $member->member_id
  },
  {
    select  =>['me.*','invitees.*'],
    join  => 'invitees',
  }

);

I know it's bad form to use ?.*, but I simplified this
for the sake of clarity.

The returned resultset only contains accessors for the
three columns in "members_invitees" and nothing for
all the other column names mentioned in the select
condition.  Turning on debug mode shows that the
executed sql is identical to the one I showed above.
When I run this sql statement through psql it returns
the expected results. So I am not sure what is going
on.  It is likely I don't understand how this is
supposed to work.  Has anyone ran into this kind of
thing before?  Can someone point me to an example that
they actually used?  Greatly appreciated.

I've attached my actual dbix classes for the tables
mentioned in case a quick look at that would help you
understand what I am trying to do.


--john

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: members.pm
Type: application/octet-stream
Size: 1796 bytes
Desc: 309290212-members.pm
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060517/449ab024/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: members_invitees.pm
Type: application/octet-stream
Size: 1238 bytes
Desc: 4163190067-members_invitees.pm
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060517/449ab024/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: invitees.pm
Type: application/octet-stream
Size: 1340 bytes
Desc: 4270429119-invitees.pm
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060517/449ab024/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: db.pm
Type: application/octet-stream
Size: 2663 bytes
Desc: 3150906821-db.pm
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060517/449ab024/attachment-0003.obj 


More information about the Dbix-class mailing list