[Zope] ZSQL field problem

McDonnell, Larry lmcdonnell@protonenergy.com
Wed, 14 Aug 2002 07:45:22 -0400


Hi,

I had a similar problem yesterday and Chris Kratz gave me the following
answer that works:

Hi Larry,

There is probably a cleaner way to do it, but we use dtml-if's to =
determine=20
whether to insert a string or a null.  It's not terribly pretty, but it =

works.

ie=20

INSERT INTO some_table(some_field)
VALUES(<dtml-if form_field><dtml-if "form_field=20
=3D=3D''">NULL<dtml-else><dtml-sqlvar form_field=20
type=3Dstring></dtml-if><dtml-else>NULL</dtml-if>

Hope this helps.

-----Original Message-----
From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of =
Colin
Fox
Sent: Tuesday, August 13, 2002 7:17 PM
To: Geir B=E6kholt
Cc: zope@zope.org
Subject: Re: [Zope] ZSQL field problem


On Tue, 2002-08-13 at 13:47, Geir B=E6kholt wrote:
> Hello Colin,=20
<..>=20
> i think type=3Dnb would work the way you want..
>=20
> (the nb means non-blank , meaning replace the empty string with NULL)

I tried making it 'type=3D"nb"', and I got:

 Invalid empty string value for birthday

I use a script to validate the form fields. I've tried:

if birthday =3D=3D '':
   birthday =3D None

but somewhere it gets turned into the string "None" instead of the
Python value None, and "None" isn't a real date.

So I took the conversion from '' to None out, and got the "Invalid =
empty
string value for birthday" error.

There must be a way to do this - you couldn't set an integer or float =
to
'' either. =20
--=20
Colin Fox                                         cfox@cfconsulting.ca
CF Consulting Inc.                                    GPG Fingerprint:
                    D8F0 84E7 E7CC 5C6C 9982  F1A7 A3EB 6EA3 BC97 572F

_______________________________________________
Zope maillist  -  Zope@zope.org
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -=20
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )