[elephant-devel] Bug in get-instances-by-value

Sebastian Georges arnaudpourseb at gmail.com
Tue Jun 24 18:26:42 UTC 2008


Hi everybody,

(elephant:defpclass messout ()
  ((message :accessor messout-message
        :initarg :message
        :initform nil
        :index t)
   (creation-date :accessor messout-creation-date
          :initarg :creation-date
          :initform nil
          :index t)
   (sent :accessor messout-sent
     :initarg :sent
     :initform "false"
     :index t))
  (:index t))

(defun queue-messout (message)
  "Add a message in the sending queue."
  (format t "Queue message for sercen: ~a~&" message)
  (make-instance 'messout :message message :creation-date
(local-time:local-time) :sent "false"))

(defun send-sercen-messout ()
  "Send a consecutive serie of messages to sercen"
  (elephant:ensure-transaction ()
    (let* ((messages (elephant:get-instances-by-value 'messout 'sent
"false"))
       (sorted-message (sort messages #'local-time:local-time< :key
'messout-creation-date)))
      (dolist (messout sorted-message)
    (format t "Send message to sercen: ~a~&" (messout-message messout))
    (setf (messout-sent messout) "true")))))


Using this class definition over a fresh bdb base with unstable, and
executing the following shows the normal behaviour.
(queue-messout "USERORG|1111|2802")
(queue-messout "USERORG|2222|2802")
(queue-messout "USERORG|3333|2802")
(queue-messout "USERORG|4444|2802")
(elephant:get-instances-by-value 'messout 'sent "false")
-> (#<MESSOUT oid:11> #<MESSOUT oid:12> #<MESSOUT oid:13> #<MESSOUT oid:14>)
(elephant:get-instances-by-value 'messout 'sent "true")
-> NIL
(send-sercen-messout)
-> NIL
(elephant:get-instances-by-value 'messout 'sent "false")
-> NIL
(elephant:get-instances-by-value 'messout 'sent "true")
-> (#<MESSOUT oid:11> #<MESSOUT oid:12> #<MESSOUT oid:13> #<MESSOUT oid:14>)


But if you replace "true" and "false" by t and nil, the two last
get-instances-by-value return exactly the same result (the whole 4 objects).
(elephant:get-instances-by-value 'messout 'sent nil)
(#<MESSOUT oid:4> #<MESSOUT oid:8> #<MESSOUT oid:9> #<MESSOUT oid:10>)
(elephant:get-instances-by-value 'messout 'sent t)
(#<MESSOUT oid:4> #<MESSOUT oid:8> #<MESSOUT oid:9> #<MESSOUT oid:10>)

Hope this is descriptive enough.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20080624/99116c72/attachment.html>


More information about the elephant-devel mailing list