Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot apply patch replacing a vector with a string #3

Open
jeremyrsellars opened this issue Nov 1, 2023 · 1 comment · May be fixed by #4
Open

Cannot apply patch replacing a vector with a string #3

jeremyrsellars opened this issue Nov 1, 2023 · 1 comment · May be fixed by #4

Comments

@jeremyrsellars
Copy link

When applying a patch that replaces a vector with a string, an exception can occur.

(require '[differ.core :as differ])
(let [old-state {:vec-or-string [{:num 0}]}
      new-state {:vec-or-string "a-string"}
      diff (differ/diff old-state new-state)]
  (prn diff)
  (differ/patch old-state diff))
[{:vec-or-string "a-string"} {:vec-or-string [{:num 0}]}]
; Execution error (ClassCastException) at differ.patch/vec-removals (patch.cljc:76).
; class clojure.lang.PersistentArrayMap cannot be cast to class java.lang.Number 

Thanks for differ!

@jeremyrsellars
Copy link
Author

FYI, I used clojure test.check to see how well things round-tripped (by applying the diff with patch). It found a number of issues. I have fixed many of them in my fork. However, backwards-compatibility wasn't really on my mind.

My company has been saving the differ.core/diff results for a many months and using it to sync state between a CLJS client and CLJ server, but sometimes it fails. This lead me to investigate, raise this issue, and work on some changes. As of tonight, I'm unsure whether this will be a permanent fork or if it will be a PR back to your repository. I welcome any insight you may have into this. Either way, I'll keep this public for a while in case you find it useful.

@jeremyrsellars jeremyrsellars linked a pull request Nov 8, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant