From bd70a82600c33fdca975c89ea968695af7386b69 Mon Sep 17 00:00:00 2001 From: Jeff Reinecke Date: Fri, 15 Apr 2011 12:08:12 -0700 Subject: [PATCH] Mongo Context: Fixed a bug where context.fetch(nil) returned the first record found instead of nil. It got this silly idea from the Mongo find_one method. --- README.rdoc | 4 ++++ lib/poro/contexts/mongo_context.rb | 1 + lib/poro/version.rb | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 4bdbce1..ed6da55 100644 --- a/README.rdoc +++ b/README.rdoc @@ -160,6 +160,10 @@ mailto:jeff@paploo.net = Version History +[0.1.8 - 2011-Apr-15] Bug Fixes. + * MongoContext: context.fetch(nil) returns nil. Turns out + Mongo's coll.find_one(nil) returned first record, and so + that is what we were doing but didn't actually want to do. [0.1.7 - 2011-Apr-06] Bug Fixes. * MongoContext: Fixed it to send :after_fetch events after a find. * MongoContext: Dereferencing a DBRef. diff --git a/lib/poro/contexts/mongo_context.rb b/lib/poro/contexts/mongo_context.rb index 31d4079..9185bca 100644 --- a/lib/poro/contexts/mongo_context.rb +++ b/lib/poro/contexts/mongo_context.rb @@ -89,6 +89,7 @@ def data_store=(collection) attr_writer :attempt_id_conversion def fetch(id) + return nil if id.nil? #find_one(nil) returns the first object! We don't want this. data = data_store.find_one( clean_id(id) ) obj = convert_to_plain_object(data) callback_event(:after_fetch, obj) diff --git a/lib/poro/version.rb b/lib/poro/version.rb index 5fe7a1c..f657d75 100644 --- a/lib/poro/version.rb +++ b/lib/poro/version.rb @@ -3,5 +3,5 @@ # existing plain ol' ruby objects as little as possible. For more information # see README.rdoc. module Poro - VERSION = '0.1.7' + VERSION = '0.1.8' end \ No newline at end of file