activerecord 5.1.2 → 5.1.3.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 +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/active_record/associations/alias_tracker.rb +9 -10
- data/lib/active_record/associations/association_scope.rb +6 -2
- data/lib/active_record/associations/collection_association.rb +1 -4
- data/lib/active_record/associations/has_many_through_association.rb +5 -0
- data/lib/active_record/associations/join_dependency.rb +3 -2
- data/lib/active_record/attribute_mutation_tracker.rb +3 -2
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/reflection.rb +2 -4
- data/lib/active_record/relation.rb +1 -1
- data/lib/active_record/scoping.rb +4 -3
- data/lib/active_record/tasks/database_tasks.rb +1 -1
- data/lib/active_record/tasks/mysql_database_tasks.rb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2235bab758b26132975903eb55a7f74d34019f9e
|
4
|
+
data.tar.gz: 5da80bcac453255f9d1da49f4a32722edd894d7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aec867ebce19311b4f1617064d94057bcf78e0de5383c43b2ccaf4a733bc9c776ef4aa73b1353662fa87eb76a7a1db49ac1367cfe639a3b3b46560c0da648715
|
7
|
+
data.tar.gz: 9fcebfae2cb8040cb7f4930f85ea11ce86d24716caba8c665ec35ca57acd7eb4690c6f03a28af23a7d0b37f44747db37d692b316efd13b8654dfe95560bdb71b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
## Rails 5.1.3.rc1 (July 19, 2017) ##
|
2
|
+
|
3
|
+
* `Relation#joins` is no longer affected by the target model's
|
4
|
+
`current_scope`, with the exception of `unscoped`.
|
5
|
+
|
6
|
+
Fixes #29338.
|
7
|
+
|
8
|
+
*Sean Griffin*
|
9
|
+
|
10
|
+
* Previously, when building records using a `has_many :through` association,
|
11
|
+
if the child records were deleted before the parent was saved, they would
|
12
|
+
still be persisted. Now, if child records are deleted before the parent is saved
|
13
|
+
on a `has_many :through` association, the child records will not be persisted.
|
14
|
+
|
15
|
+
*Tobias Kraze*
|
16
|
+
|
17
|
+
|
1
18
|
## Rails 5.1.2 (June 26, 2017) ##
|
2
19
|
|
3
20
|
* Restore previous behavior of collection proxies: their values can have
|
@@ -6,21 +6,21 @@ module ActiveRecord
|
|
6
6
|
class AliasTracker # :nodoc:
|
7
7
|
attr_reader :aliases
|
8
8
|
|
9
|
-
def self.create(connection, initial_table
|
9
|
+
def self.create(connection, initial_table)
|
10
10
|
aliases = Hash.new(0)
|
11
11
|
aliases[initial_table] = 1
|
12
|
-
new
|
12
|
+
new(connection, aliases)
|
13
13
|
end
|
14
14
|
|
15
|
-
def self.create_with_joins(connection, initial_table, joins
|
15
|
+
def self.create_with_joins(connection, initial_table, joins)
|
16
16
|
if joins.empty?
|
17
|
-
create(connection, initial_table
|
17
|
+
create(connection, initial_table)
|
18
18
|
else
|
19
19
|
aliases = Hash.new { |h, k|
|
20
20
|
h[k] = initial_count_for(connection, k, joins)
|
21
21
|
}
|
22
22
|
aliases[initial_table] = 1
|
23
|
-
new
|
23
|
+
new(connection, aliases)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -53,17 +53,16 @@ module ActiveRecord
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# table_joins is an array of arel joins which might conflict with the aliases we assign here
|
56
|
-
def initialize(connection, aliases
|
56
|
+
def initialize(connection, aliases)
|
57
57
|
@aliases = aliases
|
58
58
|
@connection = connection
|
59
|
-
@type_caster = type_caster
|
60
59
|
end
|
61
60
|
|
62
|
-
def aliased_table_for(table_name, aliased_name)
|
61
|
+
def aliased_table_for(table_name, aliased_name, type_caster)
|
63
62
|
if aliases[table_name].zero?
|
64
63
|
# If it's zero, we can have our table_name
|
65
64
|
aliases[table_name] = 1
|
66
|
-
Arel::Table.new(table_name, type_caster:
|
65
|
+
Arel::Table.new(table_name, type_caster: type_caster)
|
67
66
|
else
|
68
67
|
# Otherwise, we need to use an alias
|
69
68
|
aliased_name = @connection.table_alias_for(aliased_name)
|
@@ -76,7 +75,7 @@ module ActiveRecord
|
|
76
75
|
else
|
77
76
|
aliased_name
|
78
77
|
end
|
79
|
-
Arel::Table.new(table_name, type_caster:
|
78
|
+
Arel::Table.new(table_name, type_caster: type_caster).alias(table_alias)
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
@@ -21,7 +21,7 @@ module ActiveRecord
|
|
21
21
|
reflection = association.reflection
|
22
22
|
scope = klass.unscoped
|
23
23
|
owner = association.owner
|
24
|
-
alias_tracker = AliasTracker.create connection, association.klass.table_name
|
24
|
+
alias_tracker = AliasTracker.create connection, association.klass.table_name
|
25
25
|
chain_head, chain_tail = get_chain(reflection, association, alias_tracker)
|
26
26
|
|
27
27
|
scope.extending! reflection.extensions
|
@@ -112,7 +112,11 @@ module ActiveRecord
|
|
112
112
|
runtime_reflection = Reflection::RuntimeReflection.new(reflection, association)
|
113
113
|
previous_reflection = runtime_reflection
|
114
114
|
reflection.chain.drop(1).each do |refl|
|
115
|
-
alias_name = tracker.aliased_table_for(
|
115
|
+
alias_name = tracker.aliased_table_for(
|
116
|
+
refl.table_name,
|
117
|
+
refl.alias_candidate(name),
|
118
|
+
refl.klass.type_caster
|
119
|
+
)
|
116
120
|
proxy = ReflectionProxy.new(refl, alias_name)
|
117
121
|
previous_reflection.next = proxy
|
118
122
|
previous_reflection = proxy
|
@@ -44,10 +44,7 @@ module ActiveRecord
|
|
44
44
|
if loaded?
|
45
45
|
target.pluck(reflection.association_primary_key)
|
46
46
|
else
|
47
|
-
@association_ids ||= (
|
48
|
-
column = "#{reflection.quoted_table_name}.#{reflection.association_primary_key}"
|
49
|
-
scope.pluck(column)
|
50
|
-
)
|
47
|
+
@association_ids ||= scope.pluck(reflection.association_primary_key)
|
51
48
|
end
|
52
49
|
end
|
53
50
|
|
@@ -109,6 +109,11 @@ module ActiveRecord
|
|
109
109
|
record
|
110
110
|
end
|
111
111
|
|
112
|
+
def remove_records(existing_records, records, method)
|
113
|
+
super
|
114
|
+
delete_through_records(records)
|
115
|
+
end
|
116
|
+
|
112
117
|
def target_reflection_has_associated_record?
|
113
118
|
!(through_reflection.belongs_to? && owner[through_reflection.foreign_key].blank?)
|
114
119
|
end
|
@@ -93,7 +93,7 @@ module ActiveRecord
|
|
93
93
|
# joins # => []
|
94
94
|
#
|
95
95
|
def initialize(base, associations, joins, eager_loading: true)
|
96
|
-
@alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins
|
96
|
+
@alias_tracker = AliasTracker.create_with_joins(base.connection, base.table_name, joins)
|
97
97
|
@eager_loading = eager_loading
|
98
98
|
tree = self.class.make_tree associations
|
99
99
|
@join_root = JoinBase.new base, build(tree, base)
|
@@ -202,7 +202,8 @@ module ActiveRecord
|
|
202
202
|
node.reflection.chain.map { |reflection|
|
203
203
|
alias_tracker.aliased_table_for(
|
204
204
|
reflection.table_name,
|
205
|
-
table_alias_for(reflection, parent, reflection != node.reflection)
|
205
|
+
table_alias_for(reflection, parent, reflection != node.reflection),
|
206
|
+
reflection.klass.type_caster
|
206
207
|
)
|
207
208
|
}
|
208
209
|
end
|
@@ -26,6 +26,7 @@ module ActiveRecord
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def change_to_attribute(attr_name)
|
29
|
+
attr_name = attr_name.to_s
|
29
30
|
if changed?(attr_name)
|
30
31
|
[attributes[attr_name].original_value, attributes.fetch_value(attr_name)]
|
31
32
|
end
|
@@ -44,7 +45,7 @@ module ActiveRecord
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def changed_in_place?(attr_name)
|
47
|
-
attributes[attr_name].changed_in_place?
|
48
|
+
attributes[attr_name.to_s].changed_in_place?
|
48
49
|
end
|
49
50
|
|
50
51
|
def forget_change(attr_name)
|
@@ -54,7 +55,7 @@ module ActiveRecord
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def original_value(attr_name)
|
57
|
-
attributes[attr_name].original_value
|
58
|
+
attributes[attr_name.to_s].original_value
|
58
59
|
end
|
59
60
|
|
60
61
|
def force_change(attr_name)
|
@@ -197,10 +197,8 @@ module ActiveRecord
|
|
197
197
|
end
|
198
198
|
|
199
199
|
def klass_join_scope(table, predicate_builder) # :nodoc:
|
200
|
-
if klass.current_scope
|
201
|
-
klass.
|
202
|
-
scope.joins_values = scope.left_outer_joins_values = [].freeze
|
203
|
-
}
|
200
|
+
if klass.current_scope && klass.current_scope.values.empty?
|
201
|
+
klass.unscoped
|
204
202
|
else
|
205
203
|
relation = ActiveRecord::Relation.create(
|
206
204
|
klass,
|
@@ -332,7 +332,7 @@ module ActiveRecord
|
|
332
332
|
# Please check unscoped if you want to remove all previous scopes (including
|
333
333
|
# the default_scope) during the execution of a block.
|
334
334
|
def scoping
|
335
|
-
previous, klass.current_scope = klass.current_scope, self
|
335
|
+
previous, klass.current_scope = klass.current_scope(true), self
|
336
336
|
yield
|
337
337
|
ensure
|
338
338
|
klass.current_scope = previous
|
@@ -10,8 +10,8 @@ module ActiveRecord
|
|
10
10
|
end
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
def current_scope
|
14
|
-
ScopeRegistry.value_for(:current_scope, self)
|
13
|
+
def current_scope(skip_inherited_scope = false) # :nodoc:
|
14
|
+
ScopeRegistry.value_for(:current_scope, self, skip_inherited_scope)
|
15
15
|
end
|
16
16
|
|
17
17
|
def current_scope=(scope) #:nodoc:
|
@@ -75,8 +75,9 @@ module ActiveRecord
|
|
75
75
|
end
|
76
76
|
|
77
77
|
# Obtains the value for a given +scope_type+ and +model+.
|
78
|
-
def value_for(scope_type, model)
|
78
|
+
def value_for(scope_type, model, skip_inherited_scope = false)
|
79
79
|
raise_invalid_scope_type!(scope_type)
|
80
|
+
return @registry[scope_type][model.name] if skip_inherited_scope
|
80
81
|
klass = model
|
81
82
|
base = model.base_class
|
82
83
|
while klass <= base
|
@@ -260,7 +260,7 @@ module ActiveRecord
|
|
260
260
|
def check_schema_file(filename)
|
261
261
|
unless File.exist?(filename)
|
262
262
|
message = %{#{filename} doesn't exist yet. Run `rails db:migrate` to create it, then try again.}
|
263
|
-
message << %{ If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded.} if defined?(::Rails)
|
263
|
+
message << %{ If you do not intend to use a database, you should instead alter #{Rails.root}/config/application.rb to limit the frameworks that will be loaded.} if defined?(::Rails.root)
|
264
264
|
Kernel.abort message
|
265
265
|
end
|
266
266
|
end
|
@@ -59,8 +59,8 @@ module ActiveRecord
|
|
59
59
|
args.concat(["--no-data"])
|
60
60
|
args.concat(["--routines"])
|
61
61
|
args.concat(["--skip-comments"])
|
62
|
-
args.concat(Array(extra_flags)) if extra_flags
|
63
62
|
args.concat(["#{configuration['database']}"])
|
63
|
+
args.unshift(*extra_flags) if extra_flags
|
64
64
|
|
65
65
|
run_cmd("mysqldump", args, "dumping")
|
66
66
|
end
|
@@ -69,7 +69,7 @@ module ActiveRecord
|
|
69
69
|
args = prepare_command_options
|
70
70
|
args.concat(["--execute", %{SET FOREIGN_KEY_CHECKS = 0; SOURCE #{filename}; SET FOREIGN_KEY_CHECKS = 1}])
|
71
71
|
args.concat(["--database", "#{configuration['database']}"])
|
72
|
-
args.
|
72
|
+
args.unshift(*extra_flags) if extra_flags
|
73
73
|
|
74
74
|
run_cmd("mysql", args, "loading")
|
75
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.3.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.1.
|
19
|
+
version: 5.1.3.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.1.
|
26
|
+
version: 5.1.3.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.1.
|
33
|
+
version: 5.1.3.rc1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.1.
|
40
|
+
version: 5.1.3.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,9 +333,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
333
333
|
version: 2.2.2
|
334
334
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
335
335
|
requirements:
|
336
|
-
- - "
|
336
|
+
- - ">"
|
337
337
|
- !ruby/object:Gem::Version
|
338
|
-
version:
|
338
|
+
version: 1.3.1
|
339
339
|
requirements: []
|
340
340
|
rubyforge_project:
|
341
341
|
rubygems_version: 2.6.12
|