[Zope-dev] ZSQL and Normalized databases (or why ZSQL sucks)

Casey Duncan cduncan@kaivo.com
Thu, 19 Apr 2001 16:44:54 -0600


The Doctor What wrote:
> 
> * Paul Erickson (erickson@kaivo.com) [010419 17:02]:
> > The Doctor What wrote:
> > > > * Loosing the variable between the form and dtml-if
> >
> > I don't understand this.  I'm assuming that you are losing values that
> > are not in your argument list.  All you have to do is add the arguments.
> 
> That isn't what I mean.  Try this (typed in, so it may need to be
> adjusted):
> <param>foo=0</param>
> <dtml-if expr="foo != 0">Life is good</dtml-if>
> 
> You'll NEVER get Life is good to print out.  EVER.  This is because
> ZSQL is setting foo to 0.  But dtml-var and dtml-sqlvar both work.
> 

Reason: foo=0 is actually foo='0'. foo:int=0 should work like you want.

> >
> > Database normalization isn't really an issue.  It sounds like you're
> > really just having problems with the syntax of joins.
> 
> Nope, can do joins.  Been doing joins (mainly inner).  Not the
> problem.  The problem is that if I have tables like:
> Table1
> ------
> id
> name
> desc
> 
> Table2
> ------
> id
> Table1ID   <-- Foreign Key thrown in for fun.
> name
> desc
> 
> And I join them, then I MUST rename all the selects using AS:
> select
>   Table1.id as id1
>   Table1.name as name1
> ...etc....
> 
> Because I can't have zsql put the variables in the caller's
> namespace as "Table1.id".  It puts them in as "id" (without the AS).
> 
> Fortunately, I found the column for sqltest (which is the other end
> of ZSQL):
> <dtml-sqltest id1 column="Table1.id" ....
> 

This is a function of your field naming convention more than anything.
Granted you don't always have control over that. I am surprised that
name="spam.eggs" doesn't work on sqltests (it works everywhere else).
Are you explicitly saying name="..."? that could be the problem, bare
quoting assumes expr="..." where periods are significant.
> 
> Can I use them from a python script?  If not, what's the point?  I
> mean: External methods are nice to have when you have *no other
> choice*, but they aren't something I'd want to debug and deal with
> for object.

Python scripts are quite helpful for calling ZSQL methods. Just remember
to pass REQUEST or the arguments explicitly.

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>