datascript icon indicating copy to clipboard operation
datascript copied to clipboard

Fix upserts containing tempids in tuples

Open ash14 opened this issue 5 years ago • 2 comments

PR to address #378. Not sure how dirty the implementation is for this ... but tests pass so 🤷

Cheers.

ash14 avatar Dec 18 '20 01:12 ash14

Thank you for the bug report and the PR. This is an interesting problem :)

I feel that tempid resolution should not happen in resolve-upserts, but somewhere earlier, around

https://github.com/tonsky/datascript/blob/1f060c07dfad2a700a8be702802734266dcf0222/src/datascript/db.cljc#L1431-L1439

Basically, same code should run, but for all tuple values, not just for a single v.

Also, checking for being a tuple is better not by coll?, but by going to schema

https://github.com/tonsky/datascript/blob/1f060c07dfad2a700a8be702802734266dcf0222/src/datascript/db.cljc#L900-L902

tonsky avatar Dec 18 '20 14:12 tonsky

I've updated the test case - the entity to upsert now comes first which breaks the approach I was taking with this.

ash14 avatar Dec 21 '20 09:12 ash14