Use the :tx-data as a $-database! The only pitfall is that the second position, the attribute, and all other references (reference type) is just a reference to the attribute entity (a long).
Let's say you find :db/txInstant to be 53, and :community/category to be 112 the query would look like (q '[:find ?tx-eid . in $ :where [?tx-eid 53 _ ?tx-eid true] [_ 112 "free stuff" ?tx-eid false]] tx-data-as-database) If this query returns the ?tx-eid, and not nil, the contraints was fulfilled - test passed. Given that this is unit testing and performance is probably not a big issue, maybe it would be possible to write a function generating a datomic query like the one above, but with conveniences like it automatically inlines the attribute-entids (or extends the query to automatically looking them up using some reference to the db with the current schema installed). Given that Datomic compiles every new query that is not parameterized this could be quite heavy if it was used in production. But in short, you can query the tx-data using datalog, the only pitfall is that datoms are mostly primitives which must be looked up in the datomic db they came from. I think datoms have a reference to the database they came from, but I don't know how to use that fact. It's full of stars. /Linus On Wednesday, July 1, 2015 at 9:47:07 PM UTC+2, Alan Thompson wrote: > > Hi - I am trying to write some unit tests for Datomic using core.match to > keep things succinct. I was hoping to use a match pattern like this: > > [ {:e tx-eid :a :db/txInstant :v _ :tx tx-eid > :added true} > {:e _ :a :community/category :v "free stuff" :tx tx-eid > :added false} ] > > to show that the transaction EID (tx-eid) shows up in 3 places in the > datoms result of a transaction. However, I am getting the error: > > Exception in thread "main" java.lang.AssertionError: Pattern row 1: > Pattern row reuses wildcards in [[{:e tx-eid, :a :db/txInstant, :v _, :tx > tx-eid, :added true} {:e _, :a :community/category, :v "free stuff", :tx > tx-eid, :added false}]]. The following wildcards are ambiguous: tx-eid. > There's no guarantee that the matched values will be same. Rename the > occurrences uniquely., > > > So I am apparently unable to use core.match in the way I was hoping. Are > there any workarounds to this problem? > > Thanks, > Alan > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.