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 whether to insert a string or a null. It's not terribly pretty, but it works. ie INSERT INTO some_table(some_field) VALUES(<dtml-if form_field><dtml-if "form_field ==''">NULL<dtml-else><dtml-sqlvar form_field type=string></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ækholt Cc: zope@zope.org Subject: Re: [Zope] ZSQL field problem On Tue, 2002-08-13 at 13:47, Geir Bækholt wrote:
Hello Colin, <..> i think type=nb would work the way you want..
(the nb means non-blank , meaning replace the empty string with NULL)
I tried making it 'type="nb"', and I got: Invalid empty string value for birthday I use a script to validate the form fields. I've tried: if birthday == '': birthday = 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. -- 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 - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (1)
-
McDonnell, Larry