activerecord 3.2.5 → 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG.md +27 -0
- data/lib/active_record/associations/collection_association.rb +2 -12
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +5 -11
- data/lib/active_record/associations/has_many_association.rb +2 -6
- data/lib/active_record/associations/has_many_through_association.rb +0 -4
- data/lib/active_record/attribute_methods.rb +3 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -1
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +1 -1
- data/lib/active_record/relation/delegation.rb +5 -5
- data/lib/active_record/relation/finder_methods.rb +3 -1
- data/lib/active_record/relation/predicate_builder.rb +3 -3
- data/lib/active_record/version.rb +1 -1
- metadata +10 -10
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
## Rails 3.2.6 (Jun 12, 2012) ##
|
2
|
+
|
3
|
+
* protect against the nesting of hashes changing the
|
4
|
+
table context in the next call to build_from_hash. This fix
|
5
|
+
covers this case as well.
|
6
|
+
|
7
|
+
CVE-2012-2695
|
8
|
+
|
9
|
+
* Revert earlier 'perf fix' (see 3.2.4 changelog / GH #6289). This
|
10
|
+
change introduced a regression (GH #6609). assoc.clear and
|
11
|
+
assoc.delete_all have loaded the association before doing the delete
|
12
|
+
since at least Rails 2.3. Doing the delete without loading the
|
13
|
+
records means that the `before_remove` and `after_remove` callbacks do
|
14
|
+
not get invoked. Therefore, this change was less a fix a more an
|
15
|
+
optimisation, which should only have gone into master.
|
16
|
+
|
17
|
+
*Jon Leighton*
|
18
|
+
|
19
|
+
## Rails 3.2.5 (Jun 1, 2012) ##
|
20
|
+
|
21
|
+
* Restore behavior of Active Record 3.2.3 scopes.
|
22
|
+
A series of commits relating to preloading and scopes caused a regression.
|
23
|
+
|
24
|
+
*Andrew White*
|
25
|
+
|
26
|
+
|
1
27
|
## Rails 3.2.4 (May 31, 2012) ##
|
2
28
|
|
3
29
|
* Perf fix: Don't load the records when doing assoc.delete_all.
|
@@ -16,6 +42,7 @@
|
|
16
42
|
* Predicate builder should not recurse for determining where columns.
|
17
43
|
Thanks to Ben Murphy for reporting this! CVE-2012-2661
|
18
44
|
|
45
|
+
|
19
46
|
## Rails 3.2.3 (March 30, 2012) ##
|
20
47
|
|
21
48
|
* Added find_or_create_by_{attribute}! dynamic method. *Andrew White*
|
@@ -154,7 +154,7 @@ module ActiveRecord
|
|
154
154
|
#
|
155
155
|
# See delete for more info.
|
156
156
|
def delete_all
|
157
|
-
delete(
|
157
|
+
delete(load_target).tap do
|
158
158
|
reset
|
159
159
|
loaded!
|
160
160
|
end
|
@@ -226,17 +226,7 @@ module ActiveRecord
|
|
226
226
|
# are actually removed from the database, that depends precisely on
|
227
227
|
# +delete_records+. They are in any case removed from the collection.
|
228
228
|
def delete(*records)
|
229
|
-
|
230
|
-
|
231
|
-
if records.first == :all
|
232
|
-
if loaded? || dependent == :destroy
|
233
|
-
delete_or_destroy(load_target, dependent)
|
234
|
-
else
|
235
|
-
delete_records(:all, dependent)
|
236
|
-
end
|
237
|
-
else
|
238
|
-
delete_or_destroy(records, dependent)
|
239
|
-
end
|
229
|
+
delete_or_destroy(records, options[:dependent])
|
240
230
|
end
|
241
231
|
|
242
232
|
# Destroy +records+ and remove them from this association calling
|
@@ -47,17 +47,11 @@ module ActiveRecord
|
|
47
47
|
records = load_target if records == :all
|
48
48
|
records.each { |record| owner.connection.delete(interpolate(sql, record)) }
|
49
49
|
else
|
50
|
-
relation
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
relation[reflection.association_foreign_key].
|
56
|
-
in(records.map { |x| x.id }.compact)
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
owner.connection.delete(relation.where(condition).compile_delete)
|
50
|
+
relation = join_table
|
51
|
+
stmt = relation.where(relation[reflection.foreign_key].eq(owner.id).
|
52
|
+
and(relation[reflection.association_foreign_key].in(records.map { |x| x.id }.compact))
|
53
|
+
).compile_delete
|
54
|
+
owner.connection.delete stmt
|
61
55
|
end
|
62
56
|
end
|
63
57
|
|
@@ -89,12 +89,8 @@ module ActiveRecord
|
|
89
89
|
records.each { |r| r.destroy }
|
90
90
|
update_counter(-records.length) unless inverse_updates_counter_cache?
|
91
91
|
else
|
92
|
-
|
93
|
-
|
94
|
-
else
|
95
|
-
keys = records.map { |r| r[reflection.association_primary_key] }
|
96
|
-
scope = scoped.where(reflection.association_primary_key => keys)
|
97
|
-
end
|
92
|
+
keys = records.map { |r| r[reflection.association_primary_key] }
|
93
|
+
scope = scoped.where(reflection.association_primary_key => keys)
|
98
94
|
|
99
95
|
if method == :delete_all
|
100
96
|
update_counter(-scope.delete_all)
|
@@ -126,10 +126,6 @@ module ActiveRecord
|
|
126
126
|
def delete_records(records, method)
|
127
127
|
ensure_not_nested
|
128
128
|
|
129
|
-
# This is unoptimised; it will load all the target records
|
130
|
-
# even when we just want to delete everything.
|
131
|
-
records = load_target if records == :all
|
132
|
-
|
133
129
|
scope = through_association.scoped.where(construct_join_attributes(*records))
|
134
130
|
|
135
131
|
case method
|
@@ -181,7 +181,9 @@ module ActiveRecord
|
|
181
181
|
|
182
182
|
# Returns a hash of all the attributes with their names as keys and the values of the attributes as values.
|
183
183
|
def attributes
|
184
|
-
|
184
|
+
attrs = {}
|
185
|
+
attribute_names.each { |name| attrs[name] = read_attribute(name) }
|
186
|
+
attrs
|
185
187
|
end
|
186
188
|
|
187
189
|
# Returns an <tt>#inspect</tt>-like string for the value of the
|
@@ -42,8 +42,9 @@ module ActiveRecord
|
|
42
42
|
time = time.is_a?(String) ? Time.zone.parse(time) : time.to_time rescue time
|
43
43
|
end
|
44
44
|
time = time.in_time_zone rescue nil if time
|
45
|
+
changed = read_attribute(:#{attr_name}) != time
|
45
46
|
write_attribute(:#{attr_name}, original_time)
|
46
|
-
#{attr_name}_will_change!
|
47
|
+
#{attr_name}_will_change! if changed
|
47
48
|
@attributes_cache["#{attr_name}"] = time
|
48
49
|
end
|
49
50
|
EOV
|
@@ -375,7 +375,7 @@ module ActiveRecord
|
|
375
375
|
|
376
376
|
def tables(name = nil, database = nil, like = nil) #:nodoc:
|
377
377
|
sql = "SHOW TABLES "
|
378
|
-
sql << "IN #{database} " if database
|
378
|
+
sql << "IN #{quote_table_name(database)} " if database
|
379
379
|
sql << "LIKE #{quote(like)}" if like
|
380
380
|
|
381
381
|
execute_and_free(sql, 'SCHEMA') do |result|
|
@@ -32,12 +32,12 @@ module ActiveRecord
|
|
32
32
|
protected
|
33
33
|
|
34
34
|
def method_missing(method, *args, &block)
|
35
|
-
if
|
36
|
-
::ActiveRecord::Delegation.delegate method, :to => :to_a
|
37
|
-
to_a.send(method, *args, &block)
|
38
|
-
elsif @klass.respond_to?(method)
|
35
|
+
if @klass.respond_to?(method)
|
39
36
|
::ActiveRecord::Delegation.delegate_to_scoped_klass(method)
|
40
37
|
scoping { @klass.send(method, *args, &block) }
|
38
|
+
elsif Array.method_defined?(method)
|
39
|
+
::ActiveRecord::Delegation.delegate method, :to => :to_a
|
40
|
+
to_a.send(method, *args, &block)
|
41
41
|
elsif arel.respond_to?(method)
|
42
42
|
::ActiveRecord::Delegation.delegate method, :to => :arel
|
43
43
|
arel.send(method, *args, &block)
|
@@ -46,4 +46,4 @@ module ActiveRecord
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
@@ -190,7 +190,7 @@ module ActiveRecord
|
|
190
190
|
|
191
191
|
join_dependency = construct_join_dependency_for_association_find
|
192
192
|
relation = construct_relation_for_association_find(join_dependency)
|
193
|
-
relation = relation.except(:select, :order).select("1").limit(1)
|
193
|
+
relation = relation.except(:select, :order).select("1 AS one").limit(1)
|
194
194
|
|
195
195
|
case id
|
196
196
|
when Array, Hash
|
@@ -200,6 +200,8 @@ module ActiveRecord
|
|
200
200
|
end
|
201
201
|
|
202
202
|
connection.select_value(relation, "#{name} Exists") ? true : false
|
203
|
+
rescue ThrowResult
|
204
|
+
false
|
203
205
|
end
|
204
206
|
|
205
207
|
protected
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
class PredicateBuilder # :nodoc:
|
3
|
-
def self.build_from_hash(engine, attributes, default_table,
|
3
|
+
def self.build_from_hash(engine, attributes, default_table, allow_table_name = true)
|
4
4
|
predicates = attributes.map do |column, value|
|
5
5
|
table = default_table
|
6
6
|
|
7
|
-
if value.is_a?(Hash)
|
7
|
+
if allow_table_name && value.is_a?(Hash)
|
8
8
|
table = Arel::Table.new(column, engine)
|
9
9
|
build_from_hash(engine, value, table, false)
|
10
10
|
else
|
11
11
|
column = column.to_s
|
12
12
|
|
13
|
-
if
|
13
|
+
if allow_table_name && column.include?('.')
|
14
14
|
table_name, column = column.split('.', 2)
|
15
15
|
table = Arel::Table.new(table_name, engine)
|
16
16
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 6
|
10
|
+
version: 3.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Heinemeier Hansson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-06-
|
18
|
+
date: 2012-06-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activesupport
|
@@ -25,12 +25,12 @@ dependencies:
|
|
25
25
|
requirements:
|
26
26
|
- - "="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
hash:
|
28
|
+
hash: 3
|
29
29
|
segments:
|
30
30
|
- 3
|
31
31
|
- 2
|
32
|
-
-
|
33
|
-
version: 3.2.
|
32
|
+
- 6
|
33
|
+
version: 3.2.6
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -41,12 +41,12 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - "="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
44
|
+
hash: 3
|
45
45
|
segments:
|
46
46
|
- 3
|
47
47
|
- 2
|
48
|
-
-
|
49
|
-
version: 3.2.
|
48
|
+
- 6
|
49
|
+
version: 3.2.6
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|