-(defun canonicalize-field-types (types cursor)
- (let* ((fields (postgresql-cursor-fields cursor))
- (num-fields (length fields)))
- (cond
- ((listp types)
- (let ((length-types (length types))
- (new-types '()))
- (loop for i from 0 below num-fields
- do
- (if (>= i length-types)
- (push t new-types) ;; types is shorted than num-fields
- (push
- (case (nth i types)
- ((:int :long :double t)
- (nth i types))
- (t
- t))
- new-types)))
- (nreverse new-types)))
- ((eq types :auto)
- (let ((new-types '()))
- (dotimes (i num-fields)
- (declare (fixnum i))
- (push (canonical-field-type fields i) new-types))
- (nreverse new-types)))
- (t
- nil))))
+(defun canonicalize-types (types cursor)
+ (if (null types)
+ nil
+ (let ((auto-list (make-type-list-for-auto cursor)))
+ (cond
+ ((listp types)
+ (canonicalize-type-list types auto-list))
+ ((eq types :auto)
+ auto-list)
+ (t
+ nil)))))
+
+(defun canonicalize-type-list (types auto-list)
+ "Ensure a field type list meets expectations.
+Duplicated from clsql-uffi package so that this interface
+doesn't depend on UFFI."
+ (let ((length-types (length types))
+ (new-types '()))
+ (loop for i from 0 below (length auto-list)
+ do
+ (if (>= i length-types)
+ (push t new-types) ;; types is shorted than num-fields
+ (push
+ (case (nth i types)
+ (:int
+ (case (nth i auto-list)
+ (:int32
+ :int32)
+ (:int64
+ :int64)
+ (t
+ t)))
+ (:double
+ (case (nth i auto-list)
+ (:double
+ :double)
+ (t
+ t)))
+ (t
+ t))
+ new-types)))
+ (nreverse new-types)))
+