[Zope-DB] sqltest and sqlgroup

Dario Lopez-Kästen dario@ita.chalmers.se
Tue, 15 Jan 2002 11:34:39 +0100


From: "Smith, Neil" <Neil.Smith@npower.com>
Sent: Tuesday, January 15, 2002 10:32 AM
>
> I was expecting from the documentation that if I left any of the argumants
> empty, then that part of the where clause would be ignored, So if I test
it
> and just enter a value of Smith for the surname it should generate a
query:
>
>     select * from referrals where surname = 'Smith'
> However, on the test page, and when I try to use it, it always generates
all
> the clauses, i.e.
>     select * from referrals where (title = '' and forename = '' and
surname
> = 'Smith' )
> Am I doing something wrong, or is it not supposed to work like I thought
it
> should?
>

It's been like this forever - IIRC there was an entry for this in the
oldcollector, but I could be mistaken. No fix that I know of, or... maybe
using a construct like this:

 select * from referrals
 where
 <dtml-if title>
  title=<dtml-sqlvar title type=string>
 </dtml-if>
 <dtml-if forename>
  and forename=<dtml-sqlvar forename type=string>
 </dtml-if>
 <dtml-if surename>
  and surename=<dtml-sqlvar surname type=string>
 </dtml-if>

this is untested and really ugly, though I hope this helps...

/dario

- --------------------------------------------------------------------
Dario Lopez-Kästen     Systems Developer  Chalmers Univ. of Technology
dario@ita.chalmers.se  ICQ will yield no hits    IT Systems & Services