allow setting the odbc::*time-conversion-function* to work by
[clsql.git] / sql / command-object.lisp
index c7b0ae5c4be3b5e25e96afe2b0ca78ee2967970e..f6c57693dbb5c9db6eea7ddee51012696f488aae 100644 (file)
                      :documentation "Have we already prepared this command object")
    ))
 
+(defmethod initialize-instance :after ((o command-object) &key &allow-other-keys )
+  ;; Inits parameter nulls
+  (setf (parameters o) (parameters o)))
+
+(defmethod (setf parameters) (new (o command-object))
+  " This causes the semantics to match cl-sql instead of cl-postgresql
+  "
+  (setf (slot-value o 'parameters)
+       (loop for p in (parameters o)
+             collect (cond ((null p) :null)
+                           ((member p (list :false :F)) nil)
+                           (T p)))))
+
+(defun reset-command-object (co)
+  "Resets the command object to have no name and to be unprepared
+     (This is useful if you want to run a command against a second database)"
+  (setf (prepared-name co) ""
+       (has-been-prepared co) nil))
+
 (defun command-object (expression &optional parameters (prepared-name ""))
   (make-instance 'command-object
                 :expression expression
                 :parameters parameters
                 :prepared-name prepared-name))
 
-(export '(expression parameters prepared-name has-been-prepared command-object))
+(export '(expression parameters prepared-name has-been-prepared command-object reset-command-object))