10 May 2009
This post may be outdated due to it was written on 2009. The links may be broken. The code may be not working anymore. Leave comments if needed.
some time I'm really feeling sick when I use update_or_create or find_or_create, the default DBIx::Class::ResultSet return DBIx::Class::Row object by using find.
it's useful when I need the $row object, but it's dummy if I don't care.

I wrote DBIx::Class::ResultSet::Void today. It would use count instead of find if not defined wantarray. it means when I call
$rs->find_or_create( { id => 1, name => 'A' } );
instead of
my $row = $rs->find_or_create( { id => 1, name => 'A' } );
it would generate SQLs like:
# SELECT COUNT( * ) FROM item me WHERE ( me.id = ? ): '1'
# INSERT INTO item ( id, name) VALUES ( ?, ? ): '1', 'A'
it's a little better I think.

read more on the POD and Enjoy!


blog comments powered by Disqus