Fork me on GitHub
#datomic
<
2017-11-29
>
Empperi08:11:15

I think we just found a bug in Datomic or if it isn’t a bug then please tell me why we get an exception which leaks datomic internals? 😛

(d/q ‘[:find ?x :where [?x ?x]] (d/db db-conn))
IllegalArgumentExceptionInfo :db.error/insufficient-binding [?x-1752 ?x] not bound in expression clause: [(= ?x ?x-1752)]  datomic.error/arg (error.clj:57)
(d/q ’[:find ?x :where [?x ?x ?x]] (d/db db-conn))
IllegalArgumentExceptionInfo :db.error/insufficient-binding [?x-1773 ?x] not bound in expression clause: [(= ?x ?x-1773)]  datomic.error/arg (error.clj:57)

Empperi08:11:11

and it complains about a binding which isn’t bound in our expression but that binding is not in the original query, it’s auto generated by Datomic under the hood…

souenzzo20:11:07

## Changed in 0.9.5651
* Enhancement: Peer server allows arbitrary code in queries.
* Enhancement: Better error messages from peer server.

kennethkalmer19:11:50

Is it possible to change the parent of a component entity? ie, move a component entity from one entity to another?

Ben Kamphaus19:11:01

sounds like something that’s not a component maybe 🙂

kennethkalmer19:11:45

it definitely is, in just case though we accidentally created a duplicate of the parent (unique value got changed in source data) and now have two streams of components that I need to merge…

favila19:11:20

You can definitely move it. Retract from its existing parent and assert on the new one in the same tx

kennethkalmer19:11:34

Then it dawn on me that I could possibly transact [{:db/id component-id :parent/_id new-parent-id …}] and voila… Except not

favila19:11:52

[[:db/retract old-parent attr component][:db/add new-parent attr component]]

favila19:11:10

You cannot retract anything with the transaction map syntax

favila19:11:24

the map syntax is sugar for :db/add only

kennethkalmer19:11:47

yep, got that… in your example, what would the value of component be?

kennethkalmer19:11:01

the whole component entity as a map, or just the entity id

favila19:11:03

the component entity

favila19:11:08

only the id

kennethkalmer19:11:32

hmm, thanks, let me have a look quick

favila19:11:47

All transactions expand to a list of primitive :db/add and :db/retract operations. Map syntax is sugar for a bunch of db/adds, and transaction functions must return something that eventually bottoms out with db/add or db/retract.

favila19:11:01

db/add and retract don't take maps as arguments

kennethkalmer19:11:31

thanks, confirmed your suggestion with retract/add in the same transaction has the desired effect!

kennethkalmer19:11:04

it just never occurred to me to tackle it that way around

yannvahalewyn23:11:26

You could make a transactor fn to perform an atomic swap if you often need to query for the old parent before transacting

kennethkalmer19:11:25

I did a little repl test using d/with, and it didn’t have the behaviour I wanted

csm20:11:19

I know this was just announced, but any opinions on using global DynamoDB tables with Datomic? https://aws.amazon.com/blogs/aws/new-for-amazon-dynamodb-global-tables-and-on-demand-backup/

nickik20:11:35

Does Datomic now have some sort of Java Typed API? Or is that still in the future?