[postmodern-devel] NIL interpreted as Boolean
I have a class that looks something like this: (defclass call-request () ((phone-number :initarg :phone-number :accessor phone-number :type string :col-type string) (call-time :initarg :callback-time :accessor callback-time :type (or null simple-date:timestamp :col-type (or db-null numeric) :initform nil) (extension :initarg :extension :accessor extension :type (or string null) :col-type (or db-null string) :initform nil)) (:metaclass postmodern:dao-class) (:table-name "call_request") (:keys phone-number) (:documentation "A request to be called.")) When I try to insert a call-request with no call-time or extension, I get the error: Database error 42804: column "call_time" is of type time with time zone but expression is of type boolean You will need to rewrite or cast the expression. Query: INSERT INTO call_request (extension, callback_time, phone_number) VALUES (false, false, E'8005551212') [Condition of type CL-POSTGRES-ERROR:SYNTAX-ERROR-OR-ACCESS-VIOLATION] How do I make Postmodern interpret nil as db-null rather than boolean? Thanks, Patrick
On May 6, 2010, at 1:27 PM, Ivan Boldyrev wrote:
On Fri, May 7, 2010 at 12:25 AM, Patrick May <patrick.may@mac.com> wrote:
How do I make Postmodern interpret nil as db-null rather than boolean?
Use :null, Luke.
I tried :initform :null as well, but it gave the error: The value :NULL, derived from the initform :NULL, can not be used to set the value of the slot CALL-TIME in #<CALL-REQUEST #x30004266853D>, because it is not of type (OR NULL SIMPLE-DATE:TIMESTAMP). [Condition of type CCL::BAD-SLOT-TYPE-FROM-INITFORM] Thanks, Patrick
On Fri, May 7, 2010 at 12:34 AM, Patrick May <patrick.may@mac.com> wrote:
I tried :initform :null as well, but it gave the error:
The value :NULL, derived from the initform :NULL, can not be used to set the value of the slot CALL-TIME in #<CALL-REQUEST #x30004266853D>, because it is not of type (OR NULL SIMPLE-DATE:TIMESTAMP).
Change type of the field to (or (eql :null) simple-date:timestamp) -- Ivan Boldyrev
On May 6, 2010, at 1:47 PM, Ivan Boldyrev wrote:
On Fri, May 7, 2010 at 12:34 AM, Patrick May <patrick.may@mac.com> wrote:
I tried :initform :null as well, but it gave the error:
The value :NULL, derived from the initform :NULL, can not be used to set the value of the slot CALL-TIME in #<CALL-REQUEST #x30004266853D>, because it is not of type (OR NULL SIMPLE-DATE:TIMESTAMP).
Change type of the field to (or (eql :null) simple-date:timestamp)
Perfect, thanks! Regards, Patrick
On Fri, May 7, 2010 at 3:34 AM, Patrick May <patrick.may@mac.com> wrote:
On May 6, 2010, at 1:27 PM, Ivan Boldyrev wrote:
On Fri, May 7, 2010 at 12:25 AM, Patrick May <patrick.may@mac.com> wrote:
How do I make Postmodern interpret nil as db-null rather than boolean?
Use :null, Luke.
I tried :initform :null as well, but it gave the error:
because it is not of type (OR NULL SIMPLE-DATE:TIMESTAMP).
There is your problem right there. In your class declaration, you probably should have:
:type (or db-null simple-date:timestamp
Cheers, -- Daniel White
On May 6, 2010, at 1:34 PM, Patrick May wrote:
On May 6, 2010, at 1:27 PM, Ivan Boldyrev wrote:
On Fri, May 7, 2010 at 12:25 AM, Patrick May <patrick.may@mac.com> wrote:
How do I make Postmodern interpret nil as db-null rather than boolean?
Use :null, Luke.
I tried :initform :null as well, but it gave the error:
The value :NULL, derived from the initform :NULL, can not be used to set the value of the slot CALL-TIME in #<CALL-REQUEST #x30004266853D>, because it is not of type (OR NULL SIMPLE-DATE:TIMESTAMP). [Condition of type CCL::BAD-SLOT-TYPE-FROM-INITFORM]
Removing the :type specifiers from the class definitions eliminates the problem. It would be nice if Postmodern allowed both :type and :col-type to be used, though. Regards, Patrick
participants (3)
-
Daniel White
-
Ivan Boldyrev
-
Patrick May