[Zope-dev] Z SQL: "optional" isn't?

Kyler B. Laird laird@ecn.purdue.edu
Tue, 30 May 2000 07:38:12 EST


On Tue, 30 May 2000 17:09:20 +1000 (EST) you wrote:

>> I like the optional attribute.  I'd like to see
>> it do more than sit idle in the code.
>
>You don't have to do the typechecking in the 'arguments' box if you don't
>want. eg. in your arguments section:
>
>course=""
>subject=""

O.k., it appears that I can still use that with
integers.  I can live with that.  I don't like
setting an integer to what appears to be a
string, but it does work.

>
>select * from enrolments
><dtml-sqlgroup where>
>    <dtml-sqltest course type=int optional>
>    <dtml-sqltest subject type=nb optional>
></dtml-sqlgroup>
>
>The definition of the 'optional' tag from the docs might help here:
>    '''A flag indicating if the test is optional. If the test is optional
>    and no value is provided for a variable, or the value provided is
>    an invalid empty string, then no text is inserted'''
 
I should have been more specific.  I was
referring to the "optional" attribute of the
*argument* (not the sqltest).  I found that
it's coded in Aqueduct.py, but I'm not aware
of any way to set it from the Z SQL method
form.

>Hmm... looking at this definition, it seems you have found a bug
>(but setting the default value to "" in the arguments section will
>provide a workaround). Or maybe 'no value provided' means 'is None'.
>Anyone from DC want to provide a ruling? :-)

Originally, after reading the above ("optional"
in sqltest) definition, I'd hoped to be able to
simply list the variable in the arguments
section and make it optional in the sqltest.
After looking at the code, I determined that
this was not a reasonable expectation.  (What
if I used two sqltests and it was only optional
in one?)

In the course of investigating this, however, I
found that an optional attribute for an
argument is recognized.  It seems like this is
what should be used.

I can live with it either way, but I think that
optional is better than integer_var="". I'd
like to see whatever is chosen documented, and
I'd like to see "optional" removed from 
Aqueduct.py if it's not going to be supported.
(Maybe it's used by something else?)

--kyler