X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Foodml.lisp;h=e2f6b48eb2b5cc02c92bcd0fe201024f73163e27;hp=960dbd288282f10a36940849d8a909a2e3d123f3;hb=333e8280f2f3438ffd379349bc9746c34cccc159;hpb=225c02af1ae1c9c6f0b6c29eaf8319d48caae89f diff --git a/sql/oodml.lisp b/sql/oodml.lisp index 960dbd2..e2f6b48 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -367,16 +367,11 @@ (declare (ignore database args db-type)) "INT8") -(deftype raw-string (&optional len) - "A string which is not trimmed when retrieved from the database" +#+ignore +(deftype char (&optional len) + "A lisp type for the SQL CHAR type." `(string ,len)) -(defmethod database-get-type-specifier ((type (eql 'raw-string)) args database db-type) - (declare (ignore database db-type)) - (if args - (format nil "VARCHAR(~A)" (car args)) - "VARCHAR")) - (defmethod database-get-type-specifier ((type (eql 'float)) args database db-type) (declare (ignore database db-type)) (if args @@ -393,6 +388,23 @@ (declare (ignore args database db-type)) "BOOL") +(defmethod database-get-type-specifier ((type (eql 'number)) args database db-type) + (declare (ignore database db-type)) + (cond + ((and (consp args) (= (length args) 2)) + (format nil "NUMBER(~D,~D)" (first args) (second args))) + ((and (consp args) (= (length args) 1)) + (format nil "NUMBER(~D)" (first args))) + (t + "NUMBER"))) + +(defmethod database-get-type-specifier ((type (eql 'char)) args database db-type) + (declare (ignore database db-type)) + (if args + (format nil "CHAR(~D)" (first args)) + "CHAR")) + + (defmethod database-output-sql-as-type (type val database db-type) (declare (ignore type database db-type)) val) @@ -465,10 +477,6 @@ (declare (ignore database db-type)) val) -(defmethod read-sql-value (val (type (eql 'raw-string)) database db-type) - (declare (ignore database db-type)) - val) - (defmethod read-sql-value (val (type (eql 'keyword)) database db-type) (declare (ignore database db-type)) (when (< 0 (length val)) @@ -511,6 +519,14 @@ (declare (ignore database db-type)) (equal "t" val)) +(defmethod read-sql-value (val (type (eql 'number)) database db-type) + (declare (ignore database db-type)) + (etypecase val + (string + (unless (string-equal "NIL" val) + (read-from-string val))) + (number val))) + (defmethod read-sql-value (val (type (eql 'univeral-time)) database db-type) (declare (ignore database db-type)) (unless (eq 'NULL val)