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

:lookup does not work with :unique indexes. #58

Open
wotbrew opened this issue Feb 21, 2022 · 1 comment
Open

:lookup does not work with :unique indexes. #58

wotbrew opened this issue Feb 21, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@wotbrew
Copy link
Owner

wotbrew commented Feb 21, 2022

With :hash

(let [db {:A [{:id 1 :x 1} {:id 2 :x 1} {:id 3 :x 2}]}
      idx [[:from :A] [:hash :id]]
      db (mat db idx)]
  (q db [[:lookup idx 1]]))
=> ({:id 1, :x 1})

With :unique

(let [db {:A [{:id 1 :x 1} {:id 2 :x 1} {:id 3 :x 2}]}
      idx [[:from :A] [:unique :id]]
      db (mat db idx)]
  (q db [[:lookup idx 1]]))
=> ([:id 1] [:x 1])

Failing test and fix please :)

@wotbrew
Copy link
Owner Author

wotbrew commented Feb 21, 2022

Make sense, the lookup fn needs to somehow be specialised for :unique as it maps to single rows, rather than sets (like btree, hash).

@wotbrew wotbrew added the bug Something isn't working label Feb 21, 2022
@wotbrew wotbrew changed the title :lookup does not work if you use it with a :unique index. :lookup does not work with :unique indexes. Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant