get doesn't appear to work as expected with lambda arguments
- Dominant language
- Clojure
- Stars
- 146
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed that sometimes `r/get` doesn't work as I expect (I could be expecting the wrong thing, but the Javascript driver seems to run the same queries). For example, while testing `placeholder` from #12, I tried this code, which does not work:
``` clojure
(-> (r/table :test1)
(r/get "e549f53b-36f5-4140-97e9-61547ce75689")
(r/get-field :foo)
(placeholder
(r/lambda [id]
(-> (r/table :test2)
(r/get id))))
(run conn))
```
`ClassCastException clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.Named clojure.core/name (core.clj:1518)`
However, changing the `r/get` to `r/filter` works as expected:
``` clojure
(-> (r/table :test1)
(r/get "e549f53b-36f5-4140-97e9-61547ce75689")
(r/get-field :foo)
(placeholder
(r/lambda [id]
(-> (r/table :test2)
(r/filter {:id id}))))
(run conn))
```
In javascript (in the data explorer), the `get` version works:
``` javascript
r.table('test1').get('e549f53b-36f5-4140-97e9-61547ce75689')('foo').do(function(id){
return r.table('test2').get(id)
})
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the reported Clojure reproduction using r/get, r/lambda, placeholder, and run conn, then compare it with the working r/filter version and the JavaScript query. Done means the Clojure r/get form accepts the lambda argument and behaves like the equivalent JavaScript query without the ClassCastException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100