mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1316 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
9b1fefbf54
commit
47dcc5ffc6
3 changed files with 11 additions and 1 deletions
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Fixed use of construct_finder_sql when using :join #1288 [dwlt@dwlt.net]
|
||||||
|
|
||||||
* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
|
* Fixed that :delete_sql in has_and_belongs_to_many associations couldn't access record properties #1299 [Rick Olson]
|
||||||
|
|
||||||
* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [bitsweat]
|
* Fixed that clone would break when an aggregate had the same name as one of its attributes #1307 [bitsweat]
|
||||||
|
|
|
@ -736,7 +736,7 @@ module ActiveRecord #:nodoc:
|
||||||
|
|
||||||
def construct_finder_sql(options)
|
def construct_finder_sql(options)
|
||||||
sql = "SELECT * FROM #{table_name} "
|
sql = "SELECT * FROM #{table_name} "
|
||||||
sql << "#{options[:joins]} " if options[:joins]
|
sql << ", #{options[:joins]} " if options[:joins]
|
||||||
add_conditions!(sql, options[:conditions])
|
add_conditions!(sql, options[:conditions])
|
||||||
sql << "ORDER BY #{options[:order]} " if options[:order]
|
sql << "ORDER BY #{options[:order]} " if options[:order]
|
||||||
add_limit!(sql, options)
|
add_limit!(sql, options)
|
||||||
|
|
|
@ -276,6 +276,14 @@ class FinderTest < Test::Unit::TestCase
|
||||||
assert_equal 'fixture_9', last_two_developers.first.name
|
assert_equal 'fixture_9', last_two_developers.first.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_find_all_with_join
|
||||||
|
developers_on_project_one = Developer.find :all, :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'
|
||||||
|
|
||||||
|
assert_equal 2, developers_on_project_one.length
|
||||||
|
assert_equal 'David', developers_on_project_one.first.name
|
||||||
|
assert_equal 'Jamis', developers_on_project_one.last.name
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def bind(statement, *vars)
|
def bind(statement, *vars)
|
||||||
if vars.first.is_a?(Hash)
|
if vars.first.is_a?(Hash)
|
||||||
|
|
Loading…
Reference in a new issue