Fork me on GitHub
#datascript
<
2016-11-24
>
leov14:11:53

I have this question

leov14:11:36

why does replacing embedded document (aka 'component' field of datascript) leaves orphaned internal entities?

leov14:11:38

(let [db (d/create-conn  {:heroku.app.id  {:db/unique :db.unique/identity}
                            :w             {:db/isComponent true
                                            :db/valueType :db.type/ref}})]
    (d/transact! db
                 [{:heroku.app.id 7 :w {:a 2 :b 3}}])
    (d/transact! db
                 [{:heroku.app.id 7 :w {:c 4 :d 5}}]))

leov14:11:26

database will have 3 entities instead of 2

leov14:11:01

(I have a guess that in datomic it would be more of a feature, though, to preserve history)

Niki14:11:40

there’s no implicit delete

Niki14:11:06

you have to retract your component explicitly

leov15:11:32

so will it be a good feature to cover this case (as a memory leak in upsert scenarios), or it can be considered more as a 'byproduct of design'?

leov15:11:03

can't say if I'd be able to provide pull request that soon though

leov15:11:24

also thank you for your reply

leov15:11:45

also - what does datomic do in this case? does it auto-retract embedded document?

leov15:11:03

(so that it won't appear in queries as an orphaned entity)

leov15:11:26

hm. I guess there are some use-cases for component entities to stay, I just can't figure out which. I remember different on-delete behavior for parents in ORMs for parent-children associations