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

Document a difference between pluck and select [ci skip] #12130

Merged
merged 1 commit into from Sep 5, 2013
Merged

Document a difference between pluck and select [ci skip] #12130

merged 1 commit into from Sep 5, 2013

Conversation

egilburg
Copy link
Contributor

@egilburg egilburg commented Sep 4, 2013

Explain that pluck differs from select in that it does not construct ActiveRecord objects and thus model-level overrides are unavailable. Also explain that it triggers immediately and thus cannot be chained with further Relation scopes.

@@ -1484,6 +1484,25 @@ Client.pluck(:id)
Client.pluck(:id, :name)
```

Unlike `select`, `pluck` directly converts a database result into a Ruby `Hash`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not return a Hash but an Array

@senny
Copy link
Member

senny commented Sep 4, 2013

looks good! I also remember an issue where someone wanted to chain Relation methods onto pluck maybe you can put a sentence in there that while select returns a Relation, pluck directly returns an Array of values.

Explain that `pluck` differs from `select` in that it does not construct `ActiveRecord` objects and thus model-level overrides are unavailable.
@egilburg
Copy link
Contributor Author

egilburg commented Sep 4, 2013

Thanks, feedback addressed.

@senny
Copy link
Member

senny commented Sep 5, 2013

@egilburg this is great! 💛

senny added a commit that referenced this pull request Sep 5, 2013
Document a difference between pluck and select [ci skip]
@senny senny merged commit 390aa7a into rails:master Sep 5, 2013
@egilburg egilburg deleted the patch-1 branch September 5, 2013 07:56
senny added a commit that referenced this pull request Sep 5, 2013
Document a difference between pluck and select [ci skip]
tenderlove added a commit that referenced this pull request Sep 11, 2013
* '4-0-stable' of github.com:rails/rails:
  Merge pull request #12135 from dylanahsmith/avoid_empty_transaction
  Merge pull request #12185 from SamSaffron/join_dep
  Merge pull request #12194 from thedarkone/readonly-merger-fix
  Merge pull request #12148 from gzohari/callback-typo
  Merge pull request #12143 from rajcybage/fixing_typos
  Merge pull request #12139 from vipulnsward/typos_av
  Merge pull request #12130 from egilburg/patch-1
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.

None yet

2 participants