r11407: 28 Dec 2006 Kevin Rosenberg <kevin@rosenberg.net>
[clsql.git] / sql / expressions.lisp
index 5bce5d89c03e30d9b5118392b2d3f338aacd34e9..cd2d768c6755391dbc36bfe0cae613b8378dffa8 100644 (file)
@@ -22,7 +22,7 @@
 (defvar *sql-stream* nil
   "stream which accumulates SQL output")
 
-(defun sql-output (sql-expr &optional database)
+(defun sql-output (sql-expr &optional (database *default-database*))
   "Top-level call for generating SQL strings. Returns an SQL
   string appropriate for DATABASE which corresponds to the
   supplied lisp expression SQL-EXPR."
@@ -900,11 +900,10 @@ uninclusive, and the args from that keyword to the end."
 (defmethod database-output-sql ((tee (eql t)) database)
   (if database
       (let ((val (database-output-sql-as-type 'boolean t database (database-type database))))
-        (if val
-            (typecase val
-              (string val)
-              (t (format nil "~A" val)))
-          "'Y'"))
+        (when val
+          (typecase val
+            (string (format nil "'~A'" val))
+            (integer (format nil "~A" val)))))
     "'Y'"))
 
 #+nil(defmethod database-output-sql ((tee (eql t)) database)