diff roundup/backends/rdbms_common.py @ 2472:f41539b3c486

fixed Boolean values in postgresql (bugs [SF#972546] and [SF#972600])
author Richard Jones <richard@users.sourceforge.net>
date Wed, 16 Jun 2004 03:54:00 +0000
parents 1cd69db95b23
children ea7fb2f416db
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Wed Jun 16 00:29:54 2004 +0000
+++ b/roundup/backends/rdbms_common.py	Wed Jun 16 03:54:00 2004 +0000
@@ -1,4 +1,4 @@
-# $Id: rdbms_common.py,v 1.109 2004-06-14 03:36:11 richard Exp $
+# $Id: rdbms_common.py,v 1.110 2004-06-16 03:54:00 richard Exp $
 ''' Relational database (SQL) backend common code.
 
 Basics:
@@ -53,6 +53,12 @@
     except:
         return float(num)
 
+def _bool_cvt(value):
+    if value in ('TRUE', 'FALSE'):
+        return {'TRUE': 1, 'FALSE': 0}[value]
+    # assume it's a number returned from the db API
+    return int(value)
+
 class Database(FileStorage, hyperdb.Database, roundupdb.Database):
     ''' Wrapper around an SQL database that presents a hyperdb interface.
 
@@ -740,7 +746,7 @@
 
             prop = props[col[1:]]
             value = values[col[1:]]
-            if value:
+            if value is not None:
                 value = self.hyperdb_to_sql_value[prop.__class__](value)
             vals.append(value)
         vals.append(nodeid)
@@ -880,7 +886,7 @@
         hyperdb.Link   : str,
         hyperdb.Interval  : date.Interval,
         hyperdb.Password  : lambda x: password.Password(encrypted=x),
-        hyperdb.Boolean   : int,
+        hyperdb.Boolean   : _bool_cvt,
         hyperdb.Number    : _num_cvt,
         hyperdb.Multilink : lambda x: x,    # used in journal marshalling
     }

Roundup Issue Tracker: http://roundup-tracker.org/