Skip to content

Instantly share code, notes, and snippets.

@eggsyntax
Last active September 16, 2016 18:18
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 eggsyntax/09aa74cd86f26cffc44c79019216f182 to your computer and use it in GitHub Desktop.
Save eggsyntax/09aa74cd86f26cffc44c79019216f182 to your computer and use it in GitHub Desktop.
(ns tempdat
"Minimal example of an unexpected Datomic behavior"
(:require [datomic.api :as d]))
(def uri "datomic:mem://temp")
(d/delete-database uri) ; ensure fresh start
(d/create-database uri)
(def conn (d/connect uri))
(def schema-tx
[{:db/id #db/id[:db.part/db]
:db/ident :foo/bar
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}])
@(d/transact conn schema-tx)
(def seeds
[{:db/id #db/id[:db.part/user -1000001], :foo/bar "whatever"}])
@(d/transact conn seeds)
;; This returns a set with one item, as expected
(println "With attribute:"
(d/q '[:find ?e :where [?e :foo/bar "whatever"]] (d/db conn)))
;; But this returns an empty set, rather than (as I'd expect) a
;; set of one item
(println "Without attribute:"
(d/q '[:find ?e :where [?e _ "whatever"]] (d/db conn)))
;; Why?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment