[Zope3-dev] Re: [Zope-DB] Relational Databases in Zope 2 and Zope
Smith, Neil (Worcester)
Neil.Smith at npower.com
Tue Jun 29 04:22:14 EDT 2004
The point of the dtml-sqlgroup and dtml-sqltest is surely to provide a nice
way of handling the case where you don't pass in the parameter, so it
doesn't render the WHERE, AND, = etc. And it does this quite well.
If you remove it, then you'll need either an exponential number of SQL
methods and some logic before it to decide which to call, or you'll have to
fill the SQL method with even more confusing dtml-if statements, or you'll
have to have your SQL something like:
<dtml-sqlvar parameter_1 type=..> is null or
column_1 = <dtml-sqlvar parameter_1 type=..>
) and (
<dtml-sqlvar parameter_2 type=..> is null or
column_2 = <dtml-sqlvar parameter_2 type=..>
which again seems more confusing, (and in fact doesn't work if a parameter
is a number rather than a string).
From: Charlie Clark [mailto:charlie at egenix.com]
Sent: 29 June 2004 08:21
To: Luciano Ramalho
Cc: zope-db list; zope3-dev at zope.org
Subject: Re: [Zope3-dev] Re: [Zope-DB] Relational Databases in Zope 2
and Zope 3
On 2004-06-28 at 16:47:51 [+0200], Luciano Ramalho <ramalho at hiper.com.br>
> On Monday 28 June 2004 09:12, Charlie Clark wrote:
> > Will definitely want to drop <dtml-sqlgroup>, <dtml-sqltest> and such
> > as these do not encourage good SQL programming.
> How is it that <dtml-sqlgroup> and <dtml-sqltest> do not encourage good
> From my experience these commands allow developers to save countless hours
> creating very error-prone and hard-to-debug procedures for assembling SQL.
> <dtml-sqlgroup> and <dtml-sqltest> on the other hand change this
> chore to high level "declarative"-like programming.
> I can't see how this is bad, but I am always eager to learn and if anyone
> point me to articles explaining why these very useful commands should be
> dropped, I will look deeper into it.
Well, judging by the traffic on the Zope-DB list since I've been on it
opinions on this are divided but I think the majority of those in the
relational world are *strongly* against <dtml-sqltest> and <dtml-sqlgroup>.
They do not add functionality as they replicate SQL and introduce obscurity
as a result. While SQL has lots of problems it is important that those using
it really understand what they are writing *and* reading. If you have to be
able to understand the resultant rendered SQL you should by definition be
able to write it in the first place. And then there is the issue of
maintenance - other people might have to read your code!
That said - it is obvious some people will want to keep <dtml-sql> because
they are comfortable, happy and productive with it. So ZSQL methods will
some options to suit coding style.
There remains the issue of it would be nice to have some way of controlling
SQL statements so that code reuse in the sense of string reuse is possible,
ie. mixing in conditions or joins when appropriate. A TALES/METAL approach
this seems to me complimentary to current SQL but this discussion is only
Zope-DB mailing list
Zope-DB at zope.org
This e-mail is provided for general information purposes only and does not constitute investment or transactional advice. For the avoidance of doubt the contents of this e-mail are subject to contract and will not constitute a legally binding contract.
The information contained in this e-mail is confidential and intended only for the use of the addressee. If the reader of this message is not the addressee, you are hereby notified that you have received this e-mail in error and you must not copy, disseminate, distribute, use or take any action as a result of the information contained in it.
If you have received this e-mail in error, please notify postmaster at npower.com (UK 01384 275454) and delete it immediately from your system.
Neither Npower nor any of the other companies in the RWE Innogy group from whom this e-mail originates accept any responsibility for losses or damage as a result of any viruses and it is your responsibility to check attachments (if any) for viruses. Npower Limited Registered office: Windmill Hill Business Park, Whitehill Way, Swindon SN5 6PB. Registered in England and Wales: number 3653277. This e-mail may be sent on behalf of a member of the RWE Innogy group of companies.
More information about the Zope-DB