[Zope] [NEWBIE] Unambiguous expressions in Z SQL methods

Joel Burton joel@joelburton.com
Wed, 20 Mar 2002 08:38:06 -0500


> SELECT foo.*, bar.desc
> FROM foo
>     INNER JOIN bar ON foo.bar = bar.code
> <dtml-sqlgroup where>
>     <dtml-sqltest foo.code op="eq" type="int">
> </dtml-sqlgroup>
>
> -8<-------
>
> This works fine when I test it. However, I'm having a bit of trouble
> calling from my dtml document. I'm trying to use a line like:
>
> <dtml-in expr="listFoo(foo.code=code)">
>
> which bombs (naturally).

Biju --

First of all, rename your parameter to simply code (or foo_code if you
want). While it's not impossible to have a parameter have a dot in it, you
often have to provide a workaround for this, since Python thinks that
foo.code == subobject code of obj foo.

Often, your parameter for the ZSQLMethod has the same name as the column you
want to compare it to; in your case, your parameter is named "code" but the
column name is "foo.code".

  <dtml-sqltest code col="foo.code" op="eq" type="int">

This will resolve to

  WHERE foo.code=<dtml-sqlvar code type=int>

which is what you want


Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant