[Dbix-class] [OT][ANNOUNCE] SQL Generation with SQL::DB

Emanuele Zeppieri ema_zep at libero.it
Fri Sep 7 08:09:28 GMT 2007


Mark Lawrence wrote:

> On Fri Sep 07, 2007 at 01:23:48AM +0200, Emanuele Zeppieri wrote:
>> Mark Lawrence wrote:
> 
>>> There is another *implicit* AND between the two conditions. At first
>>> (and second glance) this is very different from the actual intended SQL,
>>> not to mention the complexity of other artifical constructs like -nest.
>>> A much better mapping can be obtained with Perl's built-in logic operators.
>> What criteria are you using to evaluate which mapping is better?
>>
>> It seems that you are talking only about readability by humans, which is
>> the less important thing, really.
> 
> ?!? You are saying code readability by humans is less important than how
> easy it is for a computer program to interpret a data structure??

I did not say anything like this.
You are either joking or deliberately manipulating my words (in the 
first case you are not funny though).

> I'm not sure why people keep thinking SQL::DB requires more string
> manipulation than SQL::Abstract. Going back to one of the examples
> I first posted:
> 
>   $schema->query(
>       select   => [$track->title, $cd->year],
>       from     => [$track, $cd],
>       distinct => 1,
>       where    => ($track->length > 248) & ! ($cd->year < 1997),
>       union    => $query2,
>   );
> 
> The arguments to the query() method is a LIST of keyword / value
> pairs (also a data structure). The keywords are not used as strings
> in the generated SQL, but are commands to SQL::DB about what type
> of data structure follows.
> 
>   my @query = (
>     construct_a => $data,
>     construct_b => $data,
>     construct_c => $data,
>   );
> 
> It is in fact the same principle as SQL::Abstract but with a
> different syntax. Nothing more, nothing less.

By the above example, it does not seem so. Not at all.

The most important thing is the WHERE clause, and it seems that it's 
implemented by a Perl expression: so how do you suppose to manipulate 
such an expression *by code* other than by string operations?

(Forget the rest, just show how do you build a complex where clause by 
code without string concatenations and such.)

Cheers,
Emanuele.



More information about the DBIx-Class mailing list