Hi, all.

I have lookup-table relationships of the following form:

__PACKAGE__->belongs_to(
    size => 'Schema::Result::SizeLookup',
    { 'foreign.size_id' => 'self.size_id' },
);


Now, I know that I can create a new row like this (all made-up
pseudocode, so please forgive any typos), and have DBIC look up the
size_id from the SizeLookup table:

$schema->resultset('TeeShirt')->create({
    serial_number => 'XYZ1234',
    size => { name => 'large' },
});


But I would really like to be able to do something *similar* to this:

$schema->resultset('TeeShirt')->create({
    serial_number => 'XYZ1234',
    size_name => 'large',
});

$tee_shirt->update({
    size_name => 'small',
});


We're a little surprised that this isn't a common desire, to be able to
create/update looked-up IDs based on the corresponding identifying
string. But we can't seem to find any off-the-shelf component that will
enable something like this.

We did see DBIx::Class::LookupColumn, but that provides additional
methods, not column-like functionality.

Any suggestions?

Tim

-- 
Tim King
Lead Developer, The Perl Shop
http://www.theperlshop.com/


_______________________________________________
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

Reply via email to