Fork me on GitHub
#datomic
<
2016-02-29
>
greywolve17:02:10

quick question, does the order matter when you use not clauses?

achesnais17:02:51

@greywolve: Hey! I was going to ask that!

achesnais17:02:04

so yeah, just to make it clearer – is there any case where clause order has an influence on the result of a query (other than impacting the query time)? Particularly when using not clauses

stuartsierra17:02:59

Clause order never has an impact on the result of a query.

stuartsierra17:02:19

From http://docs.datomic.com/query.html "Datomic will attempt to push the not clause down until all necessary variables are bound, and will throw an exception if that is not possible."

achesnais17:02:43

thanks – so, I currently have in front of me a query where, depending on the placement of the not clause vs a missing? clause, the result differs 😕

greywolve17:02:00

possible bug?

stuartsierra17:02:08

Not having seen the query, my first guess is that this would be caused by different variables being bound in the not clause from the missing? clause.

achesnais17:02:32

so clause order would impact how variables are bound?

stuartsierra17:02:23

I don't think so.

stuartsierra17:02:02

I think we would have to see a minimal test case to explain what was happening.

achesnais17:02:32

sure – I'll try and build one I can share ^^

stuartsierra17:02:09

If you don't get an answer on Slack, I would suggest posting the question to the Datomic mailing list.

stuartsierra17:02:52

You're welcome, sorry I didn't have an easy answer ready.

achesnais17:02:43

np – I totally understand you can't do much without some actual code you can run on your side

achesnais17:02:53

or even look at

stuartsierra18:02:23

@achesnais: One thing, datomic.peer is not a public API.

achesnais18:02:27

oh oops sorry

achesnais18:02:31

is it okay for me to post this snippet to the datomic mailing list though?

stuartsierra18:02:32

Also the reader literal #db/id is not meant for use in Clojure code.

stuartsierra18:02:54

And you can't transact an attribute in the same transaction in which it was defined.

stuartsierra18:02:34

After fixing those things, though, I get the same result you reported.

stuartsierra18:02:04

I admit I don't entirely understand what is happening.

stuartsierra18:02:53

It could be some subtlety related to the joining variables in not clauses.

stuartsierra18:02:56

It might even be a bug.

achesnais18:02:40

okay cool, glad someone else can reproduce. Sorry about the newbiness of my snippet

casperc22:02:55

If I am making a client for the rest API in Clojure (or actually a home made one, but still using EDN), what is a good way to make tempids if I don’t have a dependency on the datomic.api in the client?

mv22:02:52

Datomic newbie here. Do you guys usually manage your schemas directly, or do you use a tool like datomic-schema? Writing schemas seems to involve a lot of boilerplate

stuartsierra22:02:08

@casperc: Create your own datatype and render it in EDN as #db/id[:partition]

casperc22:02:49

@stuartsierra: I was actually going that way just now, I am just not sure how to make the rendering work:

(defprotocol IPrintable (toString [this]))
(deftype DbId [partition id]
  IPrintable
  (toString [this]
    (str "#db/id[" (keyword partition) (when id " " id) "]")))

casperc22:02:23

=> (str (->DbId :db.part/id nil))
"#db/id[:db.part/id]”

casperc22:02:33

=> (pr-str (->DbId :db.part/id nil))
"#object[common.datomic.client.DbId 0x57a76d2f \"#db/id[:db.part/id]\”]”

stuartsierra22:02:22

Look at the definition of pr in ClojureScript to see what protocol or multimethod it's using.

casperc22:02:02

@stuartsierra: Tricky, I was looking in Clojure’s definition, but that didn’t tell me too much tbh. I’ll look in CLJS

casperc22:02:59

Ah, actually it ends up in the print-method multimethod, so I would probably need to add a defmethod for that simple_smile

casperc22:02:47

@stuartsierra: It works, thanks for the pointer.