alexreisner / alexreisner/geocoder
Scope 'near' does not work with pluck()
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 6.4k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
Hello!
I needed to get array of only one column values from my locations table and it seems that pluck() always returns location.id, not depending what attribute is passed to the function.
Location.near('Lille')
=>
Location id: 4, area: "Lille", lat: 50.6292, lon: 3.05726, created_at: "2012-01-25 18:13:09",
Location id: 6, area: "Villeneuve-d'Ascq", lat: 50.6233, lon: 3.145, created_at: "2012-01-25 19:05:44"Location.near('Lille').pluck(:id)
=> [4, 6]Location.near('Lille').pluck(:created_at)
=> [4, 6]
Regards,
Santuxus
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing Location.near('Lille').pluck(:created_at) and compare it with the working pluck(:id) example. Trace the Location.near scope and the pluck entry point to find where the selected column is lost. Done means pluck returns the requested attribute values while preserving the near query results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100