[Zope-DB] Re: sqltest multiple doesn't work...

Wade Leftwich wade@lightlink.com
Tue, 10 Sep 2002 12:40:04 -0400

> > [Russel Hires]
> > sql, it's not so easy in dtml-sql. I've got a problem with compound
> > criteria: this works in SQL...
> >select * from condo_tbl where (bedrooms = 2 and powder_room = true) or
> >bedrooms = 3;
> >If I do this in dtml-sql:
> >select unit_number, bedrooms, weekly_rate
> >from condo_tbl
> >where <dtml-sqltest bedrooms type=int multiple>
> >I'm not able to put two values  in the test page field, and get a result.
> > I get an error:
> >Error, exceptions.ValueError: Invalid integer value for bedrooms
> >SQL used:
> >
> >Could not render the query template!
> >
> >The integer I enter is either "2 3" or "2,3" or even "(2,3)" no quotes, of
> >course.

> [Matt Kromer]
> I expect that the multiple option is expecting more than one input field
> by the same name, such that the publisher does the list conversion for
> you.  The test form is probably not capable of rendering  a pair of
> input fields of the same name.

<dtml-sqltest multiple> is expecting a single value, a list or a tuple. I 
don't think you can enter a list or a tuple on the Test page for a ZSQL 
method, so to test it you might use a script like this:

rows = container.myquery(bedrooms=[2,3])
for row in rows:
    print row.address, row.bedrooms, row.powder_room
return printed

-- Wade Leftwich
Ithaca, NY