[Dbix-class] surprise with find_or_create
Matt S Trout
dbix-class at trout.me.uk
Thu May 24 17:30:09 GMT 2007
On Thu, May 24, 2007 at 03:49:23PM +0200, Marc Espie wrote:
> I've got a simple table schema:
>
> package Artist;
>
> use base qw/DBIx::Class/;
>
> __PACKAGE__->load_components(qw/PK::Auto Core/);
> __PACKAGE__->table('artist');
> __PACKAGE__->add_columns(qw/ artistid name /);
> __PACKAGE__->set_primary_key('artistid');
>
> and I'm trying to copy an old database over.
> I've got duplicates that differ a bit, which I'd like to unify.
>
> So I tried the following:
>
> my $rs = $db->resultset('Artist');
>
> $rs->find_or_create({
> name => {like => $oldname} });
>
> the result is surprising: the new records end up having a HASH instead
> of the old names...
Er. I don't think there's a sane general way for us to handle that.
Might be an idea to make it throw an exception in a case like that?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Dbix-class
mailing list