Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch '3-2-stable-sec' into 3-2-stable

* 3-2-stable-sec:
  Strip [nil] from parameters hash. Thanks to Ben Murphy for reporting this!
  predicate builder should not recurse for determining where columns. Thanks to Ben Murphy for reporting this
  bumping to 3.2.4.rc1
  • Loading branch information...
commit d66fd081759af32e57baabf7888823cfd9bcebd0 2 parents f8f6ad6 + dff6db1
@tenderlove tenderlove authored
View
2  RAILS_VERSION
@@ -1 +1 @@
-3.2.3
+3.2.4.rc1
View
4 actionmailer/lib/action_mailer/version.rb
@@ -2,8 +2,8 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
22 actionpack/lib/action_dispatch/http/request.rb
@@ -247,6 +247,28 @@ def local?
LOCALHOST.any? { |local_ip| local_ip === remote_addr && local_ip === remote_ip }
end
+ protected
+
+ # Remove nils from the params hash
+ def deep_munge(hash)
+ hash.each_value do |v|
+ case v
+ when Array
+ v.grep(Hash) { |x| deep_munge(x) }
+ when Hash
+ deep_munge(v)
+ end
+ end
+
+ keys = hash.keys.find_all { |k| hash[k] == [nil] }
+ keys.each { |k| hash[k] = nil }
+ hash
+ end
+
+ def parse_query(qs)
+ deep_munge(super)
+ end
+
private
def check_method(name)
View
4 actionpack/lib/action_pack/version.rb
@@ -2,8 +2,8 @@ module ActionPack
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
7 actionpack/test/dispatch/request/query_string_parsing_test.rb
@@ -81,7 +81,12 @@ def teardown
end
test "query string without equal" do
- assert_parses({ "action" => nil }, "action")
+ assert_parses({"action" => nil}, "action")
+ assert_parses({"action" => {"foo" => nil}}, "action[foo]")
+ assert_parses({"action" => {"foo" => { "bar" => nil }}}, "action[foo][bar]")
+ assert_parses({"action" => {"foo" => { "bar" => nil }}}, "action[foo][bar][]")
+ assert_parses({"action" => {"foo" => nil}}, "action[foo][]")
+ assert_parses({"action"=>{"foo"=>[{"bar"=>nil}]}}, "action[foo][][bar]")
end
test "query string with empty key" do
View
4 activemodel/lib/active_model/version.rb
@@ -2,8 +2,8 @@ module ActiveModel
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
17 activerecord/lib/active_record/associations/association_scope.rb
@@ -75,7 +75,7 @@ def add_constraints(scope)
conditions.each do |condition|
if options[:through] && condition.is_a?(Hash)
- condition = { table.name => condition }
+ condition = disambiguate_condition(table, condition)
end
scope = scope.where(interpolate(condition))
@@ -114,6 +114,21 @@ def table_name_for(reflection)
end
end
+ def disambiguate_condition(table, condition)
+ if condition.is_a?(Hash)
+ Hash[
+ condition.map do |k, v|
+ if v.is_a?(Hash)
+ [k, v]
+ else
+ [table.table_alias || table.name, { k => v }]
+ end
+ end
+ ]
+ else
+ condition
+ end
+ end
end
end
end
View
6 activerecord/lib/active_record/relation/predicate_builder.rb
@@ -1,16 +1,16 @@
module ActiveRecord
class PredicateBuilder # :nodoc:
- def self.build_from_hash(engine, attributes, default_table)
+ def self.build_from_hash(engine, attributes, default_table, check_column = true)
predicates = attributes.map do |column, value|
table = default_table
if value.is_a?(Hash)
table = Arel::Table.new(column, engine)
- build_from_hash(engine, value, table)
+ build_from_hash(engine, value, table, false)
else
column = column.to_s
- if column.include?('.')
+ if check_column && column.include?('.')
table_name, column = column.split('.', 2)
table = Arel::Table.new(table_name, engine)
end
View
4 activerecord/lib/active_record/version.rb
@@ -2,8 +2,8 @@ module ActiveRecord
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
19 activerecord/test/cases/relation/where_test.rb
@@ -0,0 +1,19 @@
+require "cases/helper"
+require 'models/post'
+
+module ActiveRecord
+ class WhereTest < ActiveRecord::TestCase
+ fixtures :posts
+
+ def test_where_error
+ assert_raises(ActiveRecord::StatementInvalid) do
+ Post.where(:id => { 'posts.author_id' => 10 }).first
+ end
+ end
+
+ def test_where_with_table_name
+ post = Post.first
+ assert_equal post, Post.where(:posts => { 'id' => post.id }).first
+ end
+ end
+end
View
4 activeresource/lib/active_resource/version.rb
@@ -2,8 +2,8 @@ module ActiveResource
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
4 activesupport/lib/active_support/version.rb
@@ -2,8 +2,8 @@ module ActiveSupport
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
4 railties/lib/rails/version.rb
@@ -2,8 +2,8 @@ module Rails
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
View
4 version.rb
@@ -2,8 +2,8 @@ module Rails
module VERSION #:nodoc:
MAJOR = 3
MINOR = 2
- TINY = 3
- PRE = nil
+ TINY = 4
+ PRE = "rc1"
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
end
Please sign in to comment.
Something went wrong with that request. Please try again.