activerecord 5.1.0.rc2 → 5.1.0
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 +1 -7
- data/lib/active_record/associations/belongs_to_association.rb +1 -1
- data/lib/active_record/associations/collection_proxy.rb +18 -10
- data/lib/active_record/collection_cache_key.rb +16 -6
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +8 -6
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -2
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +4 -43
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -7
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/railties/databases.rake +2 -2
- data/lib/active_record/relation/delegation.rb +2 -0
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b681beb18e3fb91541c6c1111e35b2a339cc0938
|
4
|
+
data.tar.gz: 0314f6221b13f28cf656b1d3443588f4d67e7982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57725b96fdd14163059603613367d25276c1392c9389c1a1e79ea1993d569884da3a057869480545ab3310d01cb47e9da06116f42b8ea61c71b5e0dff2fb7bfc
|
7
|
+
data.tar.gz: e51aae2c1dace0810c3b7f572ba405a8892d07dccce8d4632540c488f875a815ab56e82c8e7de04a9bfe341c7733e4a2cc61187c2297ffefcb2a0fa000fc0f3f
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## Rails 5.1.0
|
1
|
+
## Rails 5.1.0 (April 27, 2017) ##
|
2
2
|
|
3
3
|
* Quote database name in db:create grant statement (when database_user does not have access to create the database).
|
4
4
|
|
@@ -21,9 +21,6 @@
|
|
21
21
|
|
22
22
|
*Hendy Tanata*
|
23
23
|
|
24
|
-
|
25
|
-
## Rails 5.1.0.rc1 (March 20, 2017) ##
|
26
|
-
|
27
24
|
* Remove comments from structure.sql when using postgresql adapter to avoid
|
28
25
|
version-specific parts of the file.
|
29
26
|
|
@@ -113,9 +110,6 @@
|
|
113
110
|
|
114
111
|
*Ryuta Kamizono*
|
115
112
|
|
116
|
-
|
117
|
-
## Rails 5.1.0.beta1 (February 23, 2017) ##
|
118
|
-
|
119
113
|
* Correctly dump native timestamp types for MySQL.
|
120
114
|
|
121
115
|
The native timestamp type in MySQL is different from datetime type.
|
@@ -1125,6 +1125,19 @@ module ActiveRecord
|
|
1125
1125
|
|
1126
1126
|
delegate(*delegate_methods, to: :scope)
|
1127
1127
|
|
1128
|
+
module DelegateExtending # :nodoc:
|
1129
|
+
private
|
1130
|
+
def method_missing(method, *args, &block)
|
1131
|
+
extending_values = association_scope.extending_values
|
1132
|
+
if extending_values.any? && (extending_values - self.class.included_modules).any?
|
1133
|
+
self.class.include(*extending_values)
|
1134
|
+
public_send(method, *args, &block)
|
1135
|
+
else
|
1136
|
+
super
|
1137
|
+
end
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
|
1128
1141
|
private
|
1129
1142
|
|
1130
1143
|
def find_nth_with_limit(index, limit)
|
@@ -1145,21 +1158,16 @@ module ActiveRecord
|
|
1145
1158
|
@association.find_from_target?
|
1146
1159
|
end
|
1147
1160
|
|
1161
|
+
def association_scope
|
1162
|
+
@association.association_scope
|
1163
|
+
end
|
1164
|
+
|
1148
1165
|
def exec_queries
|
1149
1166
|
load_target
|
1150
1167
|
end
|
1151
1168
|
|
1152
1169
|
def respond_to_missing?(method, _)
|
1153
|
-
|
1154
|
-
end
|
1155
|
-
|
1156
|
-
def method_missing(method, *args, &block)
|
1157
|
-
if scope.respond_to?(method) && scope.extending_values.any?
|
1158
|
-
extend(*scope.extending_values)
|
1159
|
-
public_send(method, *args, &block)
|
1160
|
-
else
|
1161
|
-
super
|
1162
|
-
end
|
1170
|
+
association_scope.respond_to?(method) || super
|
1163
1171
|
end
|
1164
1172
|
end
|
1165
1173
|
end
|
@@ -7,17 +7,27 @@ module ActiveRecord
|
|
7
7
|
if collection.loaded?
|
8
8
|
size = collection.size
|
9
9
|
if size > 0
|
10
|
-
timestamp = collection.max_by(×tamp_column).
|
10
|
+
timestamp = collection.max_by(×tamp_column)._read_attribute(timestamp_column)
|
11
11
|
end
|
12
12
|
else
|
13
13
|
column_type = type_for_attribute(timestamp_column.to_s)
|
14
14
|
column = "#{connection.quote_table_name(collection.table_name)}.#{connection.quote_column_name(timestamp_column)}"
|
15
|
+
select_values = "COUNT(*) AS #{connection.quote_column_name("size")}, MAX(%s) AS timestamp"
|
15
16
|
|
16
|
-
|
17
|
-
.
|
18
|
-
.
|
19
|
-
|
20
|
-
|
17
|
+
if collection.limit_value || collection.offset_value
|
18
|
+
query = collection.spawn
|
19
|
+
query.select_values = [column]
|
20
|
+
subquery_alias = "subquery_for_cache_key"
|
21
|
+
subquery_column = "#{subquery_alias}.#{timestamp_column}"
|
22
|
+
subquery = query.arel.as(subquery_alias)
|
23
|
+
arel = Arel::SelectManager.new(query.engine).project(select_values % subquery_column).from(subquery)
|
24
|
+
else
|
25
|
+
query = collection.unscope(:order)
|
26
|
+
query.select_values = [select_values % column]
|
27
|
+
arel = query.arel
|
28
|
+
end
|
29
|
+
|
30
|
+
result = connection.select_one(arel, nil, query.bound_attributes)
|
21
31
|
|
22
32
|
if result.blank?
|
23
33
|
size = 0
|
@@ -506,14 +506,16 @@ module ActiveRecord
|
|
506
506
|
# +conn+: an AbstractAdapter object, which was obtained by earlier by
|
507
507
|
# calling #checkout on this pool.
|
508
508
|
def checkin(conn)
|
509
|
-
synchronize do
|
510
|
-
|
509
|
+
conn.lock.synchronize do
|
510
|
+
synchronize do
|
511
|
+
remove_connection_from_thread_cache conn
|
511
512
|
|
512
|
-
|
513
|
-
|
514
|
-
|
513
|
+
conn._run_checkin_callbacks do
|
514
|
+
conn.expire
|
515
|
+
end
|
515
516
|
|
516
|
-
|
517
|
+
@available.add conn
|
518
|
+
end
|
517
519
|
end
|
518
520
|
end
|
519
521
|
|
@@ -10,8 +10,6 @@ module ActiveRecord
|
|
10
10
|
# Establishes a connection to the database that's used by all Active Record objects.
|
11
11
|
def mysql2_connection(config)
|
12
12
|
config = config.symbolize_keys
|
13
|
-
|
14
|
-
config[:username] = "root" if config[:username].nil?
|
15
13
|
config[:flags] ||= 0
|
16
14
|
|
17
15
|
if config[:flags].kind_of? Array
|
@@ -6,50 +6,8 @@ module ActiveRecord
|
|
6
6
|
true
|
7
7
|
end
|
8
8
|
|
9
|
-
def disable_referential_integrity
|
9
|
+
def disable_referential_integrity # :nodoc:
|
10
10
|
if supports_disable_referential_integrity?
|
11
|
-
if supports_alter_constraint?
|
12
|
-
disable_referential_integrity_with_alter_constraint(&block)
|
13
|
-
else
|
14
|
-
disable_referential_integrity_with_disable_trigger(&block)
|
15
|
-
end
|
16
|
-
else
|
17
|
-
yield
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def disable_referential_integrity_with_alter_constraint
|
24
|
-
tables_constraints = execute(<<-SQL).values
|
25
|
-
SELECT table_name, constraint_name
|
26
|
-
FROM information_schema.table_constraints
|
27
|
-
WHERE constraint_type = 'FOREIGN KEY'
|
28
|
-
AND is_deferrable = 'NO'
|
29
|
-
SQL
|
30
|
-
|
31
|
-
execute(
|
32
|
-
tables_constraints.collect { |table, constraint|
|
33
|
-
"ALTER TABLE #{quote_table_name(table)} ALTER CONSTRAINT #{constraint} DEFERRABLE"
|
34
|
-
}.join(";")
|
35
|
-
)
|
36
|
-
|
37
|
-
begin
|
38
|
-
transaction do
|
39
|
-
execute("SET CONSTRAINTS ALL DEFERRED")
|
40
|
-
|
41
|
-
yield
|
42
|
-
end
|
43
|
-
ensure
|
44
|
-
execute(
|
45
|
-
tables_constraints.collect { |table, constraint|
|
46
|
-
"ALTER TABLE #{quote_table_name(table)} ALTER CONSTRAINT #{constraint} NOT DEFERRABLE"
|
47
|
-
}.join(";")
|
48
|
-
)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def disable_referential_integrity_with_disable_trigger
|
53
11
|
original_exception = nil
|
54
12
|
|
55
13
|
begin
|
@@ -81,7 +39,10 @@ Rails needs superuser privileges to disable referential integrity.
|
|
81
39
|
end
|
82
40
|
rescue ActiveRecord::ActiveRecordError
|
83
41
|
end
|
42
|
+
else
|
43
|
+
yield
|
84
44
|
end
|
45
|
+
end
|
85
46
|
end
|
86
47
|
end
|
87
48
|
end
|
@@ -322,12 +322,6 @@ module ActiveRecord
|
|
322
322
|
postgresql_version >= 90400
|
323
323
|
end
|
324
324
|
|
325
|
-
def supports_alter_constraint?
|
326
|
-
# PostgreSQL 9.4 introduces ALTER TABLE ... ALTER CONSTRAINT but it has a bug and fixed in 9.4.2
|
327
|
-
# https://www.postgresql.org/docs/9.4/static/release-9-4-2.html
|
328
|
-
postgresql_version >= 90402
|
329
|
-
end
|
330
|
-
|
331
325
|
def get_advisory_lock(lock_id) # :nodoc:
|
332
326
|
unless lock_id.is_a?(Integer) && lock_id.bit_length <= 63
|
333
327
|
raise(ArgumentError, "Postgres requires advisory lock ids to be a signed 64 bit integer")
|
@@ -574,7 +568,7 @@ module ActiveRecord
|
|
574
568
|
end
|
575
569
|
|
576
570
|
def has_default_function?(default_value, default)
|
577
|
-
!default_value &&
|
571
|
+
!default_value && %r{\w+\(.*\)|\(.*\)::\w+|CURRENT_DATE|CURRENT_TIMESTAMP}.match?(default)
|
578
572
|
end
|
579
573
|
|
580
574
|
def load_additional_types(type_map, oids = nil)
|
@@ -93,7 +93,7 @@ db_namespace = namespace :db do
|
|
93
93
|
|
94
94
|
# desc 'Runs the "up" for a given migration VERSION.'
|
95
95
|
task up: [:environment, :load_config] do
|
96
|
-
raise "VERSION is required" if ENV["VERSION"]
|
96
|
+
raise "VERSION is required" if !ENV["VERSION"] || ENV["VERSION"].empty?
|
97
97
|
|
98
98
|
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
99
99
|
ActiveRecord::Migrator.run(:up, ActiveRecord::Tasks::DatabaseTasks.migrations_paths, version)
|
@@ -102,7 +102,7 @@ db_namespace = namespace :db do
|
|
102
102
|
|
103
103
|
# desc 'Runs the "down" for a given migration VERSION.'
|
104
104
|
task down: [:environment, :load_config] do
|
105
|
-
raise "VERSION is required - To go down one migration, use db:rollback" if ENV["VERSION"]
|
105
|
+
raise "VERSION is required - To go down one migration, use db:rollback" if !ENV["VERSION"] || ENV["VERSION"].empty?
|
106
106
|
version = ENV["VERSION"] ? ENV["VERSION"].to_i : nil
|
107
107
|
ActiveRecord::Migrator.run(:down, ActiveRecord::Tasks::DatabaseTasks.migrations_paths, version)
|
108
108
|
db_namespace["_dump"].invoke
|
@@ -25,6 +25,8 @@ module ActiveRecord
|
|
25
25
|
|
26
26
|
def inherited(child_class)
|
27
27
|
child_class.initialize_relation_delegate_cache
|
28
|
+
delegate = child_class.relation_delegate_class(ActiveRecord::Associations::CollectionProxy)
|
29
|
+
delegate.include ActiveRecord::Associations::CollectionProxy::DelegateExtending
|
28
30
|
super
|
29
31
|
end
|
30
32
|
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.0
|
4
|
+
version: 5.1.0
|
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-04-
|
11
|
+
date: 2017-04-27 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.0
|
19
|
+
version: 5.1.0
|
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.0
|
26
|
+
version: 5.1.0
|
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.0
|
33
|
+
version: 5.1.0
|
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.0
|
40
|
+
version: 5.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -333,12 +333,12 @@ 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: '0'
|
339
339
|
requirements: []
|
340
340
|
rubyforge_project:
|
341
|
-
rubygems_version: 2.6.
|
341
|
+
rubygems_version: 2.6.11
|
342
342
|
signing_key:
|
343
343
|
specification_version: 4
|
344
344
|
summary: Object-relational mapper framework (part of Rails).
|