[Zope] ZSQL question

Stefano Vedovelli briarsoft@iol.it
Fri, 23 Feb 2001 16:08:43 +0100


Hello

I was making some exercises, and wanted to test the <dtml-sqltest> tag. So I
wrote the following:

select * from address
<dtml-sqlgroup required where>
 <dtml-sqlgroup>
   <dtml-sqltest name column=name op=like type=string optional>
 <dtml-or>
   <dtml-sqltest name column=last_name op=like type=string optional>
 </dtml-sqlgroup>
<dtml-and>
 <dtml-sqltest company op=like type=string optional>
</dtml-sqlgroup>

Following the Zope book, that should produce:

select * from address

if no parameters specified, or:

Select * from address where (name like 'ste*' or last_name like 'ste*)

in case the name param is valid and so on. Pety that I can't make it
working. Everytime I run it, all conditions are rendered, regardless. So I
modified it this way

select * from address
<dtml-sqlgroup required where>
  <dtml-if name>
    <dtml-sqlgroup>
      <dtml-sqltest name column=name op=like type=string optional>
    <dtml-or>
      <dtml-sqltest name column=last_name op=like type=string optional>
    </dtml-sqlgroup>
  </dtml-if>
<dtml-and>
  <dtml-if company>
    <dtml-sqltest company op=like type=string optional>
  </dtml-if>
</dtml-sqlgroup>

but this way it is not like the book describes and requires some extra work,
and I think it is not in the intentions of the sqlgroup/sqltest tag
functionality. Now the question is: where I make it wrong? Note that I put
the two parameters in the ZSQL parameters list.

Thanks for the kind help!
Stefano