uhmm just figured out a very dirty solution: SELECT * FROM table <dtml-sqlgroup where> <dtml-if terminal> <dtml-let terminal="'%' + terminal +'%'"> <dtml-sqltest terminal op=like type=string> </dtml-let> </dtml-if> ...and so on... it's dirty, but gets the job done... I'd still prefer a patch to dtml-let any opinions? ----- Original Message ----- From: <alex@quad.com.ar> To: <zope@zope.org> Sent: Thursday, October 25, 2001 7:05 PM Subject: [Zope] sqltest op=like problems
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
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )