activerecord 4.0.5 → 4.0.6.rc1
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +198 -0
- data/lib/active_record/association_relation.rb +4 -0
- data/lib/active_record/associations.rb +7 -1
- data/lib/active_record/associations/builder/belongs_to.rb +3 -4
- data/lib/active_record/associations/collection_association.rb +5 -5
- data/lib/active_record/associations/collection_proxy.rb +4 -2
- data/lib/active_record/associations/has_and_belongs_to_many_association.rb +1 -1
- data/lib/active_record/associations/has_many_association.rb +4 -4
- data/lib/active_record/associations/has_many_through_association.rb +5 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +1 -1
- data/lib/active_record/associations/preloader.rb +6 -27
- data/lib/active_record/associations/preloader/association.rb +1 -1
- data/lib/active_record/associations/singular_association.rb +3 -3
- data/lib/active_record/attribute_methods.rb +1 -0
- data/lib/active_record/attribute_methods/dirty.rb +2 -2
- data/lib/active_record/attribute_methods/serialization.rb +16 -5
- data/lib/active_record/base.rb +1 -1
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +9 -12
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +1 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +6 -0
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +5 -5
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +1 -4
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +9 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +10 -5
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +7 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +6 -3
- data/lib/active_record/connection_handling.rb +2 -2
- data/lib/active_record/core.rb +1 -0
- data/lib/active_record/locking/optimistic.rb +1 -1
- data/lib/active_record/migration.rb +1 -1
- data/lib/active_record/null_relation.rb +9 -3
- data/lib/active_record/persistence.rb +9 -7
- data/lib/active_record/railties/databases.rake +2 -1
- data/lib/active_record/reflection.rb +3 -3
- data/lib/active_record/relation.rb +4 -2
- data/lib/active_record/relation/merger.rb +10 -2
- data/lib/active_record/relation/query_methods.rb +2 -2
- data/lib/active_record/scoping/default.rb +3 -3
- data/lib/active_record/store.rb +16 -4
- data/lib/active_record/test_case.rb +6 -0
- data/lib/active_record/timestamp.rb +2 -2
- data/lib/active_record/transactions.rb +1 -1
- data/lib/active_record/version.rb +1 -1
- metadata +27 -37
@@ -368,9 +368,9 @@ module ActiveRecord
|
|
368
368
|
|
369
369
|
private
|
370
370
|
def derive_class_name
|
371
|
-
class_name = name.to_s
|
371
|
+
class_name = name.to_s
|
372
372
|
class_name = class_name.singularize if collection?
|
373
|
-
class_name
|
373
|
+
class_name.camelize
|
374
374
|
end
|
375
375
|
|
376
376
|
def derive_foreign_key
|
@@ -384,7 +384,7 @@ module ActiveRecord
|
|
384
384
|
end
|
385
385
|
|
386
386
|
def derive_join_table
|
387
|
-
[active_record.table_name, klass.table_name].sort.join("\0").gsub(/^(.*_)(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_")
|
387
|
+
[active_record.table_name, klass.table_name].sort.join("\0").gsub(/^(.*[._])(.+)\0\1(.+)/, '\1\2_\3').gsub("\0", "_")
|
388
388
|
end
|
389
389
|
|
390
390
|
def primary_key(klass)
|
@@ -498,9 +498,9 @@ module ActiveRecord
|
|
498
498
|
#
|
499
499
|
# User.where(name: 'Oscar').where_values_hash
|
500
500
|
# # => {name: "Oscar"}
|
501
|
-
def where_values_hash
|
501
|
+
def where_values_hash(relation_table_name = table_name)
|
502
502
|
equalities = with_default_scope.where_values.grep(Arel::Nodes::Equality).find_all { |node|
|
503
|
-
node.left.relation.name ==
|
503
|
+
node.left.relation.name == relation_table_name
|
504
504
|
}
|
505
505
|
|
506
506
|
binds = Hash[bind_values.find_all(&:first).map { |column, v| [column.name, v] }]
|
@@ -539,6 +539,8 @@ module ActiveRecord
|
|
539
539
|
# Compares two relations for equality.
|
540
540
|
def ==(other)
|
541
541
|
case other
|
542
|
+
when Associations::CollectionProxy, AssociationRelation
|
543
|
+
self == other.to_a
|
542
544
|
when Relation
|
543
545
|
other.to_sql == to_sql
|
544
546
|
when Array
|
@@ -30,6 +30,8 @@ module ActiveRecord
|
|
30
30
|
else
|
31
31
|
other.joins!(*v)
|
32
32
|
end
|
33
|
+
elsif k == :select
|
34
|
+
other._select!(v)
|
33
35
|
else
|
34
36
|
other.send("#{k}!", v)
|
35
37
|
end
|
@@ -66,7 +68,13 @@ module ActiveRecord
|
|
66
68
|
# expensive), most of the time the value is going to be `nil` or `.blank?`, the only catch is that
|
67
69
|
# `false.blank?` returns `true`, so there needs to be an extra check so that explicit `false` values
|
68
70
|
# don't fall through the cracks.
|
69
|
-
|
71
|
+
unless value.nil? || (value.blank? && false != value)
|
72
|
+
if name == :select
|
73
|
+
relation._select!(*value)
|
74
|
+
else
|
75
|
+
relation.send("#{name}!", *value)
|
76
|
+
end
|
77
|
+
end
|
70
78
|
end
|
71
79
|
|
72
80
|
merge_multi_values
|
@@ -153,7 +161,7 @@ module ActiveRecord
|
|
153
161
|
end
|
154
162
|
|
155
163
|
def filter_binds(lhs_binds, removed_wheres)
|
156
|
-
set = Set.new removed_wheres.map { |x| x.left.name }
|
164
|
+
set = Set.new removed_wheres.map { |x| x.left.name.to_s }
|
157
165
|
lhs_binds.dup.delete_if { |col,_| set.include? col.name }
|
158
166
|
end
|
159
167
|
|
@@ -216,11 +216,11 @@ module ActiveRecord
|
|
216
216
|
to_a.select { |*block_args| yield(*block_args) }
|
217
217
|
else
|
218
218
|
raise ArgumentError, 'Call this with at least one field' if fields.empty?
|
219
|
-
spawn.
|
219
|
+
spawn._select!(*fields)
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
def
|
223
|
+
def _select!(*fields) # :nodoc:
|
224
224
|
self.select_values += fields.flatten
|
225
225
|
self
|
226
226
|
end
|
@@ -102,15 +102,15 @@ module ActiveRecord
|
|
102
102
|
self.default_scopes += [scope]
|
103
103
|
end
|
104
104
|
|
105
|
-
def build_default_scope # :nodoc:
|
105
|
+
def build_default_scope(base_rel = relation) # :nodoc:
|
106
106
|
if !Base.is_a?(method(:default_scope).owner)
|
107
107
|
# The user has defined their own default scope method, so call that
|
108
108
|
evaluate_default_scope { default_scope }
|
109
109
|
elsif default_scopes.any?
|
110
110
|
evaluate_default_scope do
|
111
|
-
default_scopes.inject(
|
111
|
+
default_scopes.inject(base_rel) do |default_scope, scope|
|
112
112
|
if !scope.is_a?(Relation) && scope.respond_to?(:call)
|
113
|
-
default_scope.merge(
|
113
|
+
default_scope.merge(base_rel.scoping { scope.call })
|
114
114
|
else
|
115
115
|
default_scope.merge(scope)
|
116
116
|
end
|
data/lib/active_record/store.rb
CHANGED
@@ -61,8 +61,9 @@ module ActiveRecord
|
|
61
61
|
extend ActiveSupport::Concern
|
62
62
|
|
63
63
|
included do
|
64
|
-
|
65
|
-
|
64
|
+
class << self
|
65
|
+
attr_accessor :local_stored_attributes
|
66
|
+
end
|
66
67
|
end
|
67
68
|
|
68
69
|
module ClassMethods
|
@@ -86,8 +87,11 @@ module ActiveRecord
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
# assign new store attribute and create new hash to ensure that each class in the hierarchy
|
91
|
+
# has its own hash of stored attributes.
|
92
|
+
self.local_stored_attributes ||= {}
|
93
|
+
self.local_stored_attributes[store_attribute] ||= []
|
94
|
+
self.local_stored_attributes[store_attribute] |= keys
|
91
95
|
end
|
92
96
|
|
93
97
|
def _store_accessors_module
|
@@ -97,6 +101,14 @@ module ActiveRecord
|
|
97
101
|
mod
|
98
102
|
end
|
99
103
|
end
|
104
|
+
|
105
|
+
def stored_attributes
|
106
|
+
parent = superclass.respond_to?(:stored_attributes) ? superclass.stored_attributes : {}
|
107
|
+
if self.local_stored_attributes
|
108
|
+
parent.merge!(self.local_stored_attributes) { |k, a, b| a | b }
|
109
|
+
end
|
110
|
+
parent
|
111
|
+
end
|
100
112
|
end
|
101
113
|
|
102
114
|
protected
|
@@ -43,7 +43,7 @@ module ActiveRecord
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
-
def
|
46
|
+
def _create_record
|
47
47
|
if self.record_timestamps
|
48
48
|
current_time = current_time_from_proper_timezone
|
49
49
|
|
@@ -57,7 +57,7 @@ module ActiveRecord
|
|
57
57
|
super
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def _update_record(*args)
|
61
61
|
if should_record_timestamps?
|
62
62
|
current_time = current_time_from_proper_timezone
|
63
63
|
|
@@ -370,7 +370,7 @@ module ActiveRecord
|
|
370
370
|
@new_record = restore_state[:new_record]
|
371
371
|
@destroyed = restore_state[:destroyed]
|
372
372
|
if restore_state.has_key?(:id)
|
373
|
-
self.
|
373
|
+
write_attribute(self.class.primary_key, restore_state[:id])
|
374
374
|
else
|
375
375
|
@attributes.delete(self.class.primary_key)
|
376
376
|
@attributes_cache.delete(self.class.primary_key)
|
metadata
CHANGED
@@ -1,78 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
5
|
-
prerelease:
|
4
|
+
version: 4.0.6.rc1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- David Heinemeier Hansson
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 4.0.
|
19
|
+
version: 4.0.6.rc1
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.0.
|
26
|
+
version: 4.0.6.rc1
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: activemodel
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - '='
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version: 4.0.
|
33
|
+
version: 4.0.6.rc1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - '='
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version: 4.0.
|
40
|
+
version: 4.0.6.rc1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: arel
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- - ~>
|
45
|
+
- - "~>"
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 4.0.0
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- - ~>
|
52
|
+
- - "~>"
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 4.0.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: activerecord-deprecated_finders
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- - ~>
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 1.0.2
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- - ~>
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.0.2
|
78
69
|
description: Databases on Rails. Build a persistent domain model by mapping database
|
@@ -89,8 +80,10 @@ files:
|
|
89
80
|
- README.rdoc
|
90
81
|
- examples/performance.rb
|
91
82
|
- examples/simple.rb
|
83
|
+
- lib/active_record.rb
|
92
84
|
- lib/active_record/aggregations.rb
|
93
85
|
- lib/active_record/association_relation.rb
|
86
|
+
- lib/active_record/associations.rb
|
94
87
|
- lib/active_record/associations/alias_tracker.rb
|
95
88
|
- lib/active_record/associations/association.rb
|
96
89
|
- lib/active_record/associations/association_scope.rb
|
@@ -110,11 +103,12 @@ files:
|
|
110
103
|
- lib/active_record/associations/has_many_through_association.rb
|
111
104
|
- lib/active_record/associations/has_one_association.rb
|
112
105
|
- lib/active_record/associations/has_one_through_association.rb
|
106
|
+
- lib/active_record/associations/join_dependency.rb
|
113
107
|
- lib/active_record/associations/join_dependency/join_association.rb
|
114
108
|
- lib/active_record/associations/join_dependency/join_base.rb
|
115
109
|
- lib/active_record/associations/join_dependency/join_part.rb
|
116
|
-
- lib/active_record/associations/join_dependency.rb
|
117
110
|
- lib/active_record/associations/join_helper.rb
|
111
|
+
- lib/active_record/associations/preloader.rb
|
118
112
|
- lib/active_record/associations/preloader/association.rb
|
119
113
|
- lib/active_record/associations/preloader/belongs_to.rb
|
120
114
|
- lib/active_record/associations/preloader/collection_association.rb
|
@@ -125,11 +119,10 @@ files:
|
|
125
119
|
- lib/active_record/associations/preloader/has_one_through.rb
|
126
120
|
- lib/active_record/associations/preloader/singular_association.rb
|
127
121
|
- lib/active_record/associations/preloader/through_association.rb
|
128
|
-
- lib/active_record/associations/preloader.rb
|
129
122
|
- lib/active_record/associations/singular_association.rb
|
130
123
|
- lib/active_record/associations/through_association.rb
|
131
|
-
- lib/active_record/associations.rb
|
132
124
|
- lib/active_record/attribute_assignment.rb
|
125
|
+
- lib/active_record/attribute_methods.rb
|
133
126
|
- lib/active_record/attribute_methods/before_type_cast.rb
|
134
127
|
- lib/active_record/attribute_methods/dirty.rb
|
135
128
|
- lib/active_record/attribute_methods/primary_key.rb
|
@@ -138,7 +131,6 @@ files:
|
|
138
131
|
- lib/active_record/attribute_methods/serialization.rb
|
139
132
|
- lib/active_record/attribute_methods/time_zone_conversion.rb
|
140
133
|
- lib/active_record/attribute_methods/write.rb
|
141
|
-
- lib/active_record/attribute_methods.rb
|
142
134
|
- lib/active_record/autosave_association.rb
|
143
135
|
- lib/active_record/base.rb
|
144
136
|
- lib/active_record/callbacks.rb
|
@@ -185,9 +177,9 @@ files:
|
|
185
177
|
- lib/active_record/locking/optimistic.rb
|
186
178
|
- lib/active_record/locking/pessimistic.rb
|
187
179
|
- lib/active_record/log_subscriber.rb
|
180
|
+
- lib/active_record/migration.rb
|
188
181
|
- lib/active_record/migration/command_recorder.rb
|
189
182
|
- lib/active_record/migration/join_table.rb
|
190
|
-
- lib/active_record/migration.rb
|
191
183
|
- lib/active_record/model_schema.rb
|
192
184
|
- lib/active_record/nested_attributes.rb
|
193
185
|
- lib/active_record/null_relation.rb
|
@@ -201,6 +193,7 @@ files:
|
|
201
193
|
- lib/active_record/railties/jdbcmysql_error.rb
|
202
194
|
- lib/active_record/readonly_attributes.rb
|
203
195
|
- lib/active_record/reflection.rb
|
196
|
+
- lib/active_record/relation.rb
|
204
197
|
- lib/active_record/relation/batches.rb
|
205
198
|
- lib/active_record/relation/calculations.rb
|
206
199
|
- lib/active_record/relation/delegation.rb
|
@@ -209,16 +202,15 @@ files:
|
|
209
202
|
- lib/active_record/relation/predicate_builder.rb
|
210
203
|
- lib/active_record/relation/query_methods.rb
|
211
204
|
- lib/active_record/relation/spawn_methods.rb
|
212
|
-
- lib/active_record/relation.rb
|
213
205
|
- lib/active_record/result.rb
|
214
206
|
- lib/active_record/runtime_registry.rb
|
215
207
|
- lib/active_record/sanitization.rb
|
216
208
|
- lib/active_record/schema.rb
|
217
209
|
- lib/active_record/schema_dumper.rb
|
218
210
|
- lib/active_record/schema_migration.rb
|
211
|
+
- lib/active_record/scoping.rb
|
219
212
|
- lib/active_record/scoping/default.rb
|
220
213
|
- lib/active_record/scoping/named.rb
|
221
|
-
- lib/active_record/scoping.rb
|
222
214
|
- lib/active_record/serialization.rb
|
223
215
|
- lib/active_record/serializers/xml_serializer.rb
|
224
216
|
- lib/active_record/statement_cache.rb
|
@@ -234,44 +226,42 @@ files:
|
|
234
226
|
- lib/active_record/timestamp.rb
|
235
227
|
- lib/active_record/transactions.rb
|
236
228
|
- lib/active_record/translation.rb
|
229
|
+
- lib/active_record/validations.rb
|
237
230
|
- lib/active_record/validations/associated.rb
|
238
231
|
- lib/active_record/validations/presence.rb
|
239
232
|
- lib/active_record/validations/uniqueness.rb
|
240
|
-
- lib/active_record/validations.rb
|
241
233
|
- lib/active_record/version.rb
|
242
|
-
- lib/active_record.rb
|
234
|
+
- lib/rails/generators/active_record.rb
|
243
235
|
- lib/rails/generators/active_record/migration/migration_generator.rb
|
244
236
|
- lib/rails/generators/active_record/migration/templates/create_table_migration.rb
|
245
237
|
- lib/rails/generators/active_record/migration/templates/migration.rb
|
246
238
|
- lib/rails/generators/active_record/model/model_generator.rb
|
247
239
|
- lib/rails/generators/active_record/model/templates/model.rb
|
248
240
|
- lib/rails/generators/active_record/model/templates/module.rb
|
249
|
-
- lib/rails/generators/active_record.rb
|
250
241
|
homepage: http://www.rubyonrails.org
|
251
242
|
licenses:
|
252
243
|
- MIT
|
244
|
+
metadata: {}
|
253
245
|
post_install_message:
|
254
246
|
rdoc_options:
|
255
|
-
- --main
|
247
|
+
- "--main"
|
256
248
|
- README.rdoc
|
257
249
|
require_paths:
|
258
250
|
- lib
|
259
251
|
required_ruby_version: !ruby/object:Gem::Requirement
|
260
|
-
none: false
|
261
252
|
requirements:
|
262
|
-
- -
|
253
|
+
- - ">="
|
263
254
|
- !ruby/object:Gem::Version
|
264
255
|
version: 1.9.3
|
265
256
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
|
-
none: false
|
267
257
|
requirements:
|
268
|
-
- -
|
258
|
+
- - ">"
|
269
259
|
- !ruby/object:Gem::Version
|
270
|
-
version:
|
260
|
+
version: 1.3.1
|
271
261
|
requirements: []
|
272
262
|
rubyforge_project:
|
273
|
-
rubygems_version:
|
263
|
+
rubygems_version: 2.2.2
|
274
264
|
signing_key:
|
275
|
-
specification_version:
|
265
|
+
specification_version: 4
|
276
266
|
summary: Object-relational mapper framework (part of Rails).
|
277
267
|
test_files: []
|