[Zope] sqltest op=like problems

alex@quad.com.ar alex@quad.com.ar
Thu, 25 Oct 2001 19:05:26 -0300


I'm trying to perform the following:

SELECT * FROM table
<dtml-sqlgroup where>
  <dtml-sqltest terminal op=like type=string optional>
<dtml-and>
  <dtml-sqltest principal op=like type=string optional>
<dtml-and>
  <dtml-sqltest product op=like type=string optional>
</dtml-sqlgroup>

if I pass only terminal and product I get the following:

SELECT * FROM table
WHERE terminal like 'foo'
AND product like 'bar'

but I need it to render like this:

SELECT * FROM table
WHERE terminal like '%foo%'
AND product like '%bar%'

so I read the mailing list archives and found out many people is doing a
<dmtl-let fieldName="'%' + fieldNamel + '%'"> but this would break my
optional attribute..
here's an example result using let on each field and passing only terminal
and product as parameters:

SELECT * FROM table
WHERE terminal like '%foo%'
AND principal like '%%'
AND product like '%bar%'

this is not tolerated since the principal field might be null, and doing a
like '%%' would discard those entries.

so, shouldn't dtml-test get patched to support at least the following op
attributes:

op=like_begin ( like '%foo' )
op=like_end ( like 'foo%' )
op=like_any ( like '%foo%' )

or is there any solution for this already?

thanks

Alex