[Dbix-class] undef vs. {}
Christopher H. Laco
claco at chrislaco.com
Mon Nov 13 19:34:48 GMT 2006
I have a resultset question. Is this by design, or by accident?
This fails
$schema->resultset('Carts')->search(undef, undef);
with:
> Use of uninitialized value in anonymous hash ({}) at C:/strawberry-perl/p=
erl/site/lib/DBIx/Class/ResultSet.pm line 190.
> DBIx::Class::ResultSet::search(): DBD::SQLite::db prepare_cached failed: =
near "IS": syntax error(1) at dbdimp.c line 269
> at C:/strawberry-perl/perl/site/lib/DBIx/Class/Storage/DBI.pm line 978.
This succeeds:
$schema->resultset('Carts')->search(undef, {});
They're both equally futile when written manually. But in things like
Handel, where I'm simply passing @_ down the line to DBIC search
sub search {
my $self =3D shift;
magic...
$schema->resultset('Carts')->search(@_);
}
$handel->search($filter, $options);
It's pita to check @_ for undefs, and strip them out, rather than
having DBIC just ignore them...
Of course, I could be off my rocker...
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061113/2a=
0c962c/signature.pgp
More information about the Dbix-class
mailing list