I just spent the day playing with my shiny new Zope installation and SQL methods, and I have been wondering if there is any reason why you can't specify a comparison operator in a sqltest directive. What I really wanted was something like: <!--#sqltest colname op=like type=string optional--> which would produce SQL like: colname like 'value' I know that I can use a construct like this: <!--#if colname--> colname like <!--#sqlvar colname--> <!--#/if--> But it is quite clumsy. If no one can come up with a reason then I might take a stab at adding an optional attribute to sqltest, something like this: Option SQL ------- ------- op=eq C = V or C in (V) if V is a list op=like C like V op=lt C < V op=le C <= V op=gt C > V op=ge C >= V op=ne C <= V where C is the column name and V is the value of the variable. Does the order of the comparisons make sense? Should it be "C op V" or "V op C" ? Obviously, only "op=eq" will work with lists, though I guess I could generate something like: ( C like V[0] or C like V[1] or ... ) for "op=like" with a list though I'm not sure of the utility. I had a quick look at the source, in sqltest.py, and I don't think it will be hard to add this. Can anyone come up with a reason why this doesn't make sense? Hugh
participants (1)
-
Hugh Emberson