dtml-comma for sqlgroup in ZSQL Method

Bug #142775 reported by Alfons Grabher
2
Affects Status Importance Assigned to Milestone
Zope 2
Fix Released
Medium
Tres Seaver

Bug Description

For UPDATE a dtml-comma is missing in sqlgroup. I found a patch at http://www.zope.org/Members/natsukashi/Patches/zope-2.2.1-sqlgroup-p1.txt but i hate patching a running system. Would like to have something similar in Zope.

Tags: bug zope
Revision history for this message
T. Middleton (timtoo) wrote :

ZSQL is frustrating in that it seems like such a great and convenient idea for templating SQL statements... but as soon as you start doing much besides SELECT statements one finds a lot of things missing. I too noticed this dtml-comma patch floating around for a long time. Why hasn't it been applied to the Zope distribution yet? It adds something, and harms nothing.(And if only ZSQL could handle NULLs on UPDATEs without horrible awkwardness)!

Revision history for this message
Florent Guillaume (efge) wrote :

For those of us not familiar with ZSQL, could you expand a bit on
"for UPDATE a dtml-comma is missing in sqlgroup".

Please state the problem in the existing code, and what the solution brings.

Revision history for this message
Andrew Veitch (andyv) wrote :

Imagine a ZSQL method called editPerson(firstname, surname, age)

It would be useful if it could be called as editPerson(firstname='Bill') or editPerson(age=99) or editPerson(surname='Gates', age=19) but this is quite tricky to render using the existing ZSQL methods. You would have to do something like:

arguments:firstname surname age
UPDATE person SET
id=id
<dtml-if firstname>,firstname=<dtml-sqlvar firstname type=string></dtml-if>
<dtml-if surname>,surname=<dtml-sqlvar surname type=string></dtml-if>
<dtml-if age>,age=<dtml-sqlvar age type=int></dtml-if>

Note the I'm assuming the table has a field called id which can be used as a dummy variable to get round the comma problem. This gets very confusing. As a further complication the scoping rules for <dtml-if> are slightly different to <dtml-sqlvar>.

This is exactly the same problem that happens with SQL where and is solved with <dtml-sqlgroup>

Using the proposed patch (from August 2000!) the above code could be simplified to:

UPDATE person
<dtml-sqlgroup set>
  firstname=<dtml-sqlvar firstname type=nb>
<dtml-comma>
  surname=<dtml-sqlvar surname type=nb>
<dtml-comma>
  age=<dtml-sqlvar age type=int>
</dtml-sqlgroup>

Revision history for this message
Tres Seaver (tseaver) wrote :

Status: Pending => Accepted

 Supporters added: tseaver

Revision history for this message
Tres Seaver (tseaver) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.