Hey this is cool. Which doc is this in? If its not currently supported for existing records, it'd be great if it became standard - I'd hate to rely on something that was dropped on a future version of DBIC because it wasn't official.
On 7/07/2009, at 01:02 PM, Jason Galea wrote:

The docs appear to indicate that you can't do this when the related foreign row already exists, but it seems to work for me..

my $customer = $self->schema->resultset('customer')->create({
 name => 'Acme Corp',
 status_id => { name => 'new'},
});

cheers,

J


Dan Horne wrote:
Say I have a table called customer which links to a parent table called status. I wonder if there is a shortcut so that I don't need to figure out the parent id in advance if I know the unique name.

my $status = $self->schema->resultset('Status')- >search({status_name => 'new'})->single;

my $customer = $self->schema->resultset->create({
   name => 'Acme Corp',
   status_id => $status->id
})

I've had a peruse of the Cookbook, but couldn't see anything

_______________________________________________
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/[email protected]

_______________________________________________
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/[email protected]


_______________________________________________
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/[email protected]

Reply via email to