[Dbix-class] RE: SQL Generation with SQL::DB

Emanuele Zeppieri ema_zep at libero.it
Fri Sep 7 13:12:31 GMT 2007


Mark Lawrence wrote:

>     foreach my $field ($form->param) {
>         my @vals = $form->param($field) or next;
>         $expr    = $expr & ( @vals > 1 ? $table->$field->in(@vals)
>                                        : $table->$field == $vals[0] );
>     }

Mark, this is more or less what I was asking for, but it seems to 
reproduce what Pagaltzis was saying (except that it doesn't uses the 
unnecessary reduce's ;-)

Thus it leads to the same objections I told him, at least when applied 
to a more general case:

1. If you have both &'s and |'s in your (full) expression, how can you 
find the correct order to evaluate the various subexpressions?

2. This way you are evaluating the (whole) expression (binary) 
subexpression by subexpression, so you are basically bypassing your 
parser (that should be able to handle more complex logic expressions, 
not just binary ones, from what I understand).
Doesn't this defeat the whole logic under your module?

That's why I was talking about string concatenations to build the whole 
expression *before* evaluating it: though I don't like it in such a 
situation it's even preferable since it saves you from (pre-)parsing the 
expression in your code to find the correct subexpressions evaluation 
order (and from a series of other parsing problems).

Cheers,
Emanuele.



More information about the DBIx-Class mailing list