[Zope] dtml-sqltest and capital column names

Oliver Bleutgen Oliver Bleutgen <myzope@gmx.net>
Thu, 12 Oct 2000 21:33:16 +0200


Hi,

I'm using zope 2.2.2 with postgres 7.0.2 and ZPopyDA 0.6.4.

I encountered a problem with dtml-sqltest and capitals in column names.

Well, I simply couldn't get it to work because postgres requires
column-names with "special characters" like capitals to be enclosed
with quotation marks, ie. "COLUMNNAME" instead of COLUMNNAME -
IIRC '_' also won't work.

The problem is that dtml-sqltest only renders

  select * from table where COLUMNNAME='5' 
which will be interpreted by postgres like
  select * from table where columnname='5'


Unfortunatly <dtml-sqltest bla column="BLA" type=int> throws the
obvious error and everything else I tried didn't work too.

In the end I patched lib/python/Shared/DC/ZRDB/sqltest.py
to do what I want.

165,166c165,166

<         if has_key('column'): self.column=args['column']
<         else: self.column=self.__name__
---
>         if has_key('column'): self.column='"'+args['column']+'"'
>         else: self.column='"'+self.__name__+'"'


Any comment whether this would also apply/be necessary for other dbs?
And if not, would there a better place (anywhere in ZPopyDA)
to change/add some code?
Or did I just miss something obvious and there's a sane way 
to make dtml-sqltest work with postgres and capitals.

cheers,
oliver