diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-21 11:02:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-21 11:02:15 -0700 |
commit | 68a97e81187358ae8a4d59499d9afc2f09d35d24 (patch) | |
tree | 93b9cd36021c746545de70d2f658b446fa71d910 /activerecord/lib/active_record/querying.rb | |
parent | eb2bb7d56f1eefb96a99321b18ed7b4b7ef1d4d6 (diff) | |
parent | ac70ec64138765ddd2a7c5e0130243e6df98cf2d (diff) | |
download | rails-68a97e81187358ae8a4d59499d9afc2f09d35d24.tar.gz rails-68a97e81187358ae8a4d59499d9afc2f09d35d24.tar.bz2 rails-68a97e81187358ae8a4d59499d9afc2f09d35d24.zip |
Merge branch 'master' into experiment
* master: (49 commits)
avoid creating a set if no where values are removed
remove bind values for where clauses that were removed
push partitioning up so bind elimination can get the removed wheres
push partion logic down and initialization logic up
the rake task `db:test:prepare` needs to load the configuration
In batches test @total was assigned but not used. Use it in tests instead of Post.count
partition the where values so we can access the removed ones
eliminate some conditionals
change method name to reflect what it actually does.
save the where values in variables so we don't need to look them up all the time
pass where values to the helper function rather than rely on internal state
Spelling correction in Upgrading Guide
Add has_named_route? to the mapper API
No need CHANGELOG entry for a test fix
Fix wrong `case_sensitive` in uniqueness validity test
Fix typo in test name and documentation
Missing ending ``` at 14.2 Merging of scopes
copy edits[ci skip]
Revert "Corrected documentation and added some more for the classify method in inflectors"
Revert "Changed the CHANGELOG for active_support and improved the doc for inflector method classify"
...
Diffstat (limited to 'activerecord/lib/active_record/querying.rb')
-rw-r--r-- | activerecord/lib/active_record/querying.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/querying.rb b/activerecord/lib/active_record/querying.rb index f78ccb01aa..3d85898c41 100644 --- a/activerecord/lib/active_record/querying.rb +++ b/activerecord/lib/active_record/querying.rb @@ -14,7 +14,7 @@ module ActiveRecord # Executes a custom SQL query against your database and returns all the results. The results will # be returned as an array with columns requested encapsulated as attributes of the model you call # this method from. If you call <tt>Product.find_by_sql</tt> then the results will be returned in - # a Product object with the attributes you specified in the SQL query. + # a +Product+ object with the attributes you specified in the SQL query. # # If you call a complicated SQL query which spans multiple tables the columns specified by the # SELECT will be attributes of the model, whether or not they are columns of the corresponding @@ -29,9 +29,10 @@ module ActiveRecord # Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id" # # => [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...] # - # # You can use the same string replacement techniques as you can with ActiveRecord#find + # You can use the same string replacement techniques as you can with <tt>ActiveRecord::QueryMethods#where</tt>: + # # Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date] - # # => [#<Post:0x36bff9c @attributes={"title"=>"The Cheap Man Buys Twice"}>, ...] + # Post.find_by_sql ["SELECT body FROM comments WHERE author = :user_id OR approved_by = :user_id", { :user_id => user_id }] def find_by_sql(sql, binds = []) result_set = connection.select_all(sanitize_sql(sql), "#{name} Load", binds) column_types = {} |