Skip to content

Allow maps and sets in paths - #36

Open
dscarpetti wants to merge 9 commits into
masterfrom
set-map-keys
Open

Allow maps and sets in paths#36
dscarpetti wants to merge 9 commits into
masterfrom
set-map-keys

Conversation

@dscarpetti

Copy link
Copy Markdown
Owner

See #34

@dscarpetti

Copy link
Copy Markdown
Owner Author

@Frozenlock, per #34, I reserved hex codes 0xa0-0xaf for future use. Do you have any additional thoughts before this gets merged?

@Frozenlock

Copy link
Copy Markdown
Contributor

Unfortunately, looking deeper into this I don't think this implementation works.

The encode doesn't result in the same value depending on the map order:

(cpath/encode {:a 1, {:k :b} 2})
;=> "¢ ia\01_001x1\0\0 ¢ ik\0ib\0\0\01_001x2\0\0\0"

(cpath/encode {{:k :b} 2, :a 1})
;=> "¢ ¢ ik\0ib\0\0\01_001x2\0\0 ia\01_001x1\0\0\0"
(def db (c/open-database! "test-db"))
(c/destroy-database! "test-db")
(let [k1 {:a 1, {:k :b} 2}
      k2 {{:k :b} 2, :a 1}]
  (c/assoc-at! db [k1] "test")
  (c/get-at! db [k2]))
;; => nil

(let [k1 {:a 1, {:k :b} 2}
      k2 {{:k :b} 2, :a 1}]
  (-> (assoc-in {} [k1] "test")
      (get-in [k2])))
;; => "test"

@dscarpetti

Copy link
Copy Markdown
Owner Author

Good catch. I think that issue is now fixed. I added a tests in codax.pathwise-test for the specific case above and some fuzz testing that randomizes map orderings.

@Frozenlock

Copy link
Copy Markdown
Contributor

As far as I can tell, this is fixed and works well. Time for a new release? 😀

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 this pull request may close these issues.

2 participants