[Zope3-dev] Re: [Zope-DB] Relational Databases in Zope 2 and Zope
3
Scot McSweeney-Roberts
zope at mcsweeney-roberts.co.uk
Tue Jun 29 08:10:05 EDT 2004
Charlie Clark wrote:
>On 2004-06-29 at 12:52:53 [+0200], "Smith, Neil (Worcester)"
><Neil.Smith at npower.com> wrote:
>
>
>> <params>
>> product
>> colour
>> size
>> available
>> </params>
>> select * from products
>> <dtml-sqlgroup where>
>> <dtml-sqltest product type=nb optional>
>> <dtml-and>
>> <dtml-sqltest colour type=nb optional>
>> <dtml-and>
>> <dtml-sqltest size type=nb optional>
>> <dtml-and>
>> <dtml-sqltest available op=gt type=int optional>
>> </dtml-sqlgroup>
>>
>>
>>
>
> select * from products
> WHERE 1 = 1
> <dtml-if product>
> AND product = <dtml-sqlvar product type=nb optional>
> </dtml-if>
> <dtml-if colour>
> AND colour = <dtml-sqlvar colour type=nb optional>
> </dtml-if>
> <dtml-if size>
> AND size = <dtml-sqlvar size type=nb optional>
> </dtml-if>
> <dtml-if>
> AND available > <dtml-sqlvar available type=int optional>
> </dtml-if>
>
>This isn't much longer has the advantage of being virtually pure SQL so
>imminently more readable.
>
>
I have to completly disagree, I find your code is far less readable. For
a start, I find WHERE 1=1 to be a kludge, something I was releaved to
find that I no longer needed with <dtml-sqlgroup where>. It also more
long winded requireing extra closing tags and ANDs. I'm not that
concerened Neil's code isn't as 'pure' SQL as yours (in the same way as
I'm not concerned that my page templates aren't 'pure' HTML) - anyone
with a good understanding of SQL who's read the Relational Database
section of the Zope book should be quite capable of understanding what's
going on - even without the Zope book it's still reasonbly clear.
cheers
Scot
More information about the Zope-DB
mailing list