ribelo / doxa

The Unlicense
232 stars 8 forks source link

negative ints as ids? #13

Closed spacegangster closed 3 years ago

spacegangster commented 3 years ago

Hey, it's all working great so far: commits, edits, diffs. Thanks again for writing this! ❤️

New question I've been using this technique – when I'm creating an entity on the client – I give it a negative int id, which is then recognised on the server as a client id. Server persists entity, generates permanent positive int id and dispatches an update. This allows to have all ids as integers.

If I commit this to doxa [:dx/put {:db/id -1, :m/gist ""}] I get this error [core.cljc:180 2021-05-20T19:30:28.372Z ERROR [ribelo.doxa:334] - invalid commit [:dx/put {:db/id -1, :m/gist ""}]

Which may be caused by timbre's limitations. I'm fine without negative ids.

If you want to support this – I can supply a failing test case and maybe help more.


Full trace

core.cljc:180 2021-05-20T19:30:28.372Z ERROR [ribelo.doxa:334] - invalid commit [:dx/put {:db/id -1, :m/gist ""}]
eval @ core.cljc:180
eval @ timbre.cljc:664
eval @ core.cljs:6973
eval @ core.cljs:6973
cljs$core$_kv_reduce @ core.cljs:713
cljs$core$reduce_kv @ core.cljs:2578
eval @ timbre.cljc:613
ribelo$doxa$_submit_commit_$_state__62565 @ doxa.cljc:334
ribelo$doxa$_submit_commit_$_state__62564_$_state__62576 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62575 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62574 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62573 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62572 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62571 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62570 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62569 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62568 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62567_$_state__62585 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62567_$_state__62584 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62567 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564_$_state__62566 @ doxa.cljc:198
ribelo$doxa$_submit_commit_$_state__62564 @ doxa.cljc:198
eval @ doxa.cljc:198
ribelo$doxa$_submit_commit @ doxa.cljc:198
eval @ doxa.cljc:396
eval @ doxa.cljc:479
eval @ doxa.cljc:477
eval @ events.cljs:67
eval @ std_interceptors.cljc:133
re_frame$std_interceptors$fx_handler__GT_interceptor_$_fx_handler_before @ std_interceptors.cljc:131
re_frame$interceptor$invoke_interceptor_fn @ interceptor.cljc:70
re_frame$interceptor$invoke_interceptors @ interceptor.cljc:108
re_frame$interceptor$execute @ interceptor.cljc:201
re_frame$events$handle @ events.cljc:65
eval @ router.cljc:179
eval @ router.cljc:198
eval @ router.cljc:146
eval @ router.cljc:169
G__38319 @ router.cljc:187
channel.port1.onmessage @ nexttick.js:218
Show 10 more frames

Source: (just replace the new-id with -1) https://github.com/spacegangster/rf-doxa-etude/blob/main/src/rf_doxa/events.cljs#L66

ribelo commented 3 years ago

There is not much to change or help, but thank you for your proposal. Done.