Last active
September 16, 2016 18:18
-
-
Save eggsyntax/09aa74cd86f26cffc44c79019216f182 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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