X-Git-Url: http://git.kpe.io/?p=clsql.git;a=blobdiff_plain;f=sql%2Foodml.lisp;h=e2f6b48eb2b5cc02c92bcd0fe201024f73163e27;hp=d44b90b75caad8484d3f3cb48007599ecefc2481;hb=333e8280f2f3438ffd379349bc9746c34cccc159;hpb=e622ee6f4bf2b9fe81af59d566e651c983a4833b diff --git a/sql/oodml.lisp b/sql/oodml.lisp index d44b90b..e2f6b48 100644 --- a/sql/oodml.lisp +++ b/sql/oodml.lisp @@ -1,7 +1,7 @@ ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*- ;;;; ************************************************************************* ;;;; -;;;; $Id: +;;;; $Id$ ;;;; ;;;; The CLSQL Object Oriented Data Manipulation Language (OODML). ;;;; @@ -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) @@ -1057,11 +1073,4 @@ as elements of a list." (record-caches database)) results) results) -(defun update-cached-results (targets qualifiers database) - ;; FIXME: this routine will need to update slots in cached objects, perhaps adding or removing objects from cached - ;; for now, dump cache entry and perform fresh search - (let ((res (apply #'find-all targets qualifiers))) - (setf (gethash (compute-records-cache-key targets qualifiers) - (record-caches database)) res) - res))