Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 22, 2012
@arohner arohner Return nil, rather than (ref nil), when a row isn't found on a table …
…using refs.
a6097c9
@arohner arohner Merge pull request #4 from circleci/fix-refs
Return nil, rather than (ref nil), when a row isn't found on a table usi...
f094f68
Showing with 10 additions and 8 deletions.
  1. +2 −1 src/mongofinil/core.clj
  2. +8 −7 test/mongofinil/test_refs.clj
View
3 src/mongofinil/core.clj
@@ -65,7 +65,8 @@
output? (fn [& args]
(let [results (apply f args)]
(throw-if-not (seq? results) "expected seq")
- (map ref results)))
+ (map #(when %
+ (ref %)) results)))
input? (fn [& args]
(throw-if-not (-> args first ref?) "Expecting ref, got %s" (first args))
(apply f @(first args) (rest args)))
View
15 test/mongofinil/test_refs.clj
@@ -75,11 +75,11 @@
(resolve 'find-one-by-y!) => nil
;; empty
- @(find-one-by-x 3) => nil
- @(find-one-by-w 2) => nil
+ (find-one-by-x 3) => nil
+ (find-one-by-w 2) => nil
(find-by-w 2) => '()
- @(find-one-by-x! 3) => (throws Exception "Couldn't find row with :x=3 on collection :xs")
- @(find-one-by-w! 2) => (throws Exception "Couldn't find row with :w=2 on collection :xs")))
+ (find-one-by-x! 3) => (throws Exception "Couldn't find row with :x=3 on collection :xs")
+ (find-one-by-w! 2) => (throws Exception "Couldn't find row with :w=2 on collection :xs")))
(fact "find-by-id works"
(let [obj (create! {:x 5 :y 6})
@@ -101,7 +101,7 @@
(create! {:x 5 :y 6})
@(find-one) => (contains {:x 5 :y 6})
@(find-one {:y 6}) => (contains {:x 5 :y 6})
- @(find-one {:y 7}) => nil)
+ (find-one {:y 7}) => nil)
(fact "keyword works"
@(create! {:x 5 :kw :asd}) => (contains {:x 5 :kw :asd})
@@ -196,12 +196,13 @@
;; check defaults
(count (where {:dx 5})) => 2)
-
-;.;. For every disciplined effort, there is a multiple reward. -- Rohn
(fact "`all and :keywords work together"
(create! {:kw "state"})
(-> (all) first deref :kw) => :state)
+(fact "find doesn't return refs pointing at nil"
+ (find-one {:x :bogus}) => nil
+ (seq (where {:x :bogus})) => nil)
(future-fact "transient doesnt stop things being loaded from the DB"
(congo/insert! :xs {:disx 55 :x 55})

No commit comments for this range

Something went wrong with that request. Please try again.