Skip to content

Instantly share code, notes, and snippets.

@boxxxie
Created May 7, 2013 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boxxxie/09bf48ebdfcfc0f99433 to your computer and use it in GitHub Desktop.
Save boxxxie/09bf48ebdfcfc0f99433 to your computer and use it in GitHub Desktop.
(defn find-by-lcode-name [lcode-name db]
(flatten (d/q '[:find ?e
:in $ ?lcode-name
:where
[?e :place/lcode_name ?lcode-name]
]
db lcode-name)))
(testing "testing the query on an empty dataset"
(let [db [[]]
found-by-lcode (find-by-lcode-name 0 db)
]
(is (not (seq found-by-lcode)))))
;;this throws
;;ERROR in (find-by-lcode-name-q-unit) (datalog.clj:935)
;;Uncaught exception, not in assertion.
;;expected: nil
;; actual: java.lang.Exception: processing rule: (q__6245 ?e)
;; at datomic.datalog$eval_rule$fn__6735.invoke (datalog.clj:935)
;; datomic.datalog$eval_rule.invoke (datalog.clj:915)
;; datomic.datalog$eval_query.invoke (datalog.clj:957)
;; datomic.datalog$qsqr.invoke (datalog.clj:1011)
;; datomic.datalog$qsqr.invoke (datalog.clj:979)
;; datomic.query$q.invoke (query.clj:448)
;; datomic.api$q.doInvoke (api.clj:31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment