[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
r5193 - in trunk/gnue-common/src/schema: . scripter/processors
From: |
reinhard |
Subject: |
r5193 - in trunk/gnue-common/src/schema: . scripter/processors |
Date: |
Sat, 28 Feb 2004 14:50:47 -0600 (CST) |
Author: reinhard
Date: 2004-02-28 14:50:46 -0600 (Sat, 28 Feb 2004)
New Revision: 5193
Modified:
trunk/gnue-common/src/schema/GSData.py
trunk/gnue-common/src/schema/scripter/processors/SQL.py
trunk/gnue-common/src/schema/scripter/processors/postgresql.py
Log:
Fix boolean conversion.
Modified: trunk/gnue-common/src/schema/GSData.py
===================================================================
--- trunk/gnue-common/src/schema/GSData.py 2004-02-28 20:20:42 UTC (rev
5192)
+++ trunk/gnue-common/src/schema/GSData.py 2004-02-28 20:50:46 UTC (rev
5193)
@@ -138,6 +138,19 @@
# =============================================================================
+# Field value is not a valid boolean
+# =============================================================================
+
+class EInvalidBoolean (EInvalidFormat):
+ """
+ Exception class for invalid formatted booleans
+ """
+ def __init__ (self, gsValue, fieldValue):
+ fmt = _("is not a boolean (TRUE or FALSE)")
+ EInvalidFormat.__init__ (self, gsValue, fieldValue, fmt)
+
+
+# =============================================================================
# Field value is not a valid date
# =============================================================================
@@ -231,16 +244,6 @@
return fieldValue
- # booleans must be 'TRUE' or 'FALSE', otherwise they're "None"
- elif fieldType == "boolean":
- bool = fieldValue.upper ().strip ()
-
- if bool in ["TRUE", "FALSE"]:
- return bool == "TRUE"
- else:
- return None
-
-
# create a number according to length and scale
elif fieldType == "number":
value = fieldValue.strip ()
@@ -278,6 +281,17 @@
else:
return int (value)
+
+ # booleans must be 'TRUE' or 'FALSE', otherwise they're "None"
+ elif fieldType == "boolean":
+ bool = fieldValue.upper ().strip ()
+
+ if bool in ["TRUE", "FALSE"]:
+ return bool == "TRUE"
+ else:
+ raise EInvalidBoolean (gsValue, fieldValue)
+
+
# Dates must conform with the ISO spec: YYYY-MM-DD
elif fieldType == "date":
try:
Modified: trunk/gnue-common/src/schema/scripter/processors/SQL.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/SQL.py 2004-02-28
20:20:42 UTC (rev 5192)
+++ trunk/gnue-common/src/schema/scripter/processors/SQL.py 2004-02-28
20:50:46 UTC (rev 5193)
@@ -325,7 +325,7 @@
"""
Use 1 for TRUE and 0 for FALSE
"""
- if gsValue:
+ if gsValue.value:
return 1
else:
return 0
Modified: trunk/gnue-common/src/schema/scripter/processors/postgresql.py
===================================================================
--- trunk/gnue-common/src/schema/scripter/processors/postgresql.py
2004-02-28 20:20:42 UTC (rev 5192)
+++ trunk/gnue-common/src/schema/scripter/processors/postgresql.py
2004-02-28 20:50:46 UTC (rev 5193)
@@ -151,7 +151,7 @@
"""
Use 1 for TRUE and 0 for FALSE
"""
- if gsValue:
+ if gsValue.value:
return "TRUE"
else:
return "FALSE"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- r5193 - in trunk/gnue-common/src/schema: . scripter/processors,
reinhard <=