r1294@iwill: jeremy | 2005-06-13 02:17:42 -0700

Ticket #1281
 r1295@iwill:  jeremy | 2005-06-13 02:50:50 -0700
 Apply patch, tweak, and test.
 r1296@iwill:  jeremy | 2005-06-13 02:51:04 -0700
 Changelog entry.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1410 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2005-06-13 04:42:36 +00:00
parent fa7f4a0664
commit 76e4c1a558
3 changed files with 16 additions and 3 deletions

View File

@ -1,5 +1,7 @@
*SVN* *SVN*
* Fixed sanitized conditions for has_many finder method. #1281 [jackc@hylesanderson.com, pragdave, Tobias Luetke]
* Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org] * Comprehensive PostgreSQL schema support. Use the optional schema_search_path directive in database.yml to give a comma-separated list of schemas to search for your tables. This allows you, for example, to have tables in a shared schema without having to use a custom table name. See http://www.postgresql.org/docs/8.0/interactive/ddl-schemas.html to learn more. #827 [dave@cherryville.org]
* Corrected @@configurations typo #1410 [david@ruppconsulting.com] * Corrected @@configurations typo #1410 [david@ruppconsulting.com]

View File

@ -66,7 +66,9 @@ module ActiveRecord
load_target.select { |record| ids.include?(record.id) } load_target.select { |record| ids.include?(record.id) }
end end
else else
options[:conditions] = @finder_sql + (options[:conditions] ? " AND #{options[:conditions]}" : "") if options[:conditions] = sanitize_sql(options[:conditions])
options[:conditions] = "#{@finder_sql} AND #{options[:conditions]}"
end
if options[:order] && @options[:order] if options[:order] && @options[:order]
options[:order] = "#{options[:order]}, #{@options[:order]}" options[:order] = "#{options[:order]}, #{@options[:order]}"

View File

@ -345,16 +345,25 @@ class HasManyAssociationsTest < Test::Unit::TestCase
def test_find_all_sanitized def test_find_all_sanitized
firm = Firm.find_first firm = Firm.find_first
assert_equal firm.clients.find_all("name = 'Summit'"), firm.clients.find_all(["name = '%s'", "Summit"]) assert_equal firm.clients.find_all("name = 'Summit'"), firm.clients.find_all(["name = '%s'", "Summit"])
summit = firm.clients.find(:all, :conditions => "name = 'Summit'")
assert_equal summit, firm.clients.find(:all, :conditions => ["name = ?", "Summit"])
assert_equal summit, firm.clients.find(:all, :conditions => ["name = :name", { :name => "Summit" }])
end end
def test_find_first def test_find_first
firm = Firm.find_first firm = Firm.find_first
client2 = Client.find(2)
assert_equal firm.clients.first, firm.clients.find_first assert_equal firm.clients.first, firm.clients.find_first
assert_equal Client.find(2), firm.clients.find_first("type = 'Client'") assert_equal client2, firm.clients.find_first("type = 'Client'")
assert_equal client2, firm.clients.find(:first, :conditions => "type = 'Client'")
end end
def test_find_first_sanitized def test_find_first_sanitized
assert_equal Client.find(2), Firm.find_first.clients.find_first(["type = ?", "Client"]) firm = Firm.find_first
client2 = Client.find(2)
assert_equal client2, firm.clients.find_first(["type = ?", "Client"])
assert_equal client2, firm.clients.find(:first, :conditions => ['type = ?', 'Client'])
assert_equal client2, firm.clients.find(:first, :conditions => ['type = :type', { :type => 'Client' }])
end end
def test_find_in_collection def test_find_in_collection