From 6f94e9de5f373b1d3975eff35327e22d9775b502 Mon Sep 17 00:00:00 2001 From: Cyrus Harmon Date: Wed, 2 Nov 2016 12:19:58 -0700 Subject: [PATCH] accept nil function for set-sql-reader * in which case we remove the hash table entry for the specified oid, resulting in using the default type interpreter (and reading the type as text) --- cl-postgres/interpret.lisp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/cl-postgres/interpret.lisp b/cl-postgres/interpret.lisp index 9fa07c7..7a3f50a 100644 --- a/cl-postgres/interpret.lisp +++ b/cl-postgres/interpret.lisp @@ -56,18 +56,20 @@ this type." (defun set-sql-reader (oid function &key (table *sql-readtable*) binary-p) "Add an sql reader to a readtable. When the reader is not binary, it is wrapped by a function that will read the string from the socket." - (setf (gethash oid table) - (make-instance 'type-interpreter - :oid oid - :use-binary binary-p - :binary-reader - (when binary-p function) - :text-reader - (if binary-p - 'interpret-as-text - (lambda (stream size) - (funcall function - (enc-read-string stream :byte-length size)))))) + (if function + (setf (gethash oid table) + (make-instance 'type-interpreter + :oid oid + :use-binary binary-p + :binary-reader + (when binary-p function) + :text-reader + (if binary-p + 'interpret-as-text + (lambda (stream size) + (funcall function + (enc-read-string stream :byte-length size)))))) + (remhash oid table)) table) (defmacro binary-reader (fields &body value) -- 2.11.4.GIT