activerecord 5.1.1 → 5.1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 394e7cfd6bb07ff7a39f17ac4746817abf40d198
4
- data.tar.gz: 3574ab9e38c9e64fed64345d15e75eef9d76d213
3
+ metadata.gz: 8fa5485b13d997e01ea2c6bc8d83bdac475b943a
4
+ data.tar.gz: ec29464443b6789257407f6acdd6bd8423fb0c7e
5
5
  SHA512:
6
- metadata.gz: 1420d3477fdea2c92a8a5c9dd821b9a8ea95b434c4801c3eb51136f226c2ce61f025f9cf4fa27bc53ddd5d9020f6ecc10caa6dc265fa0da3ee0e9c7efb6b061e
7
- data.tar.gz: 742c1f4c15c1e18c7ecd57410825f4338931cdd50f44143157c75bd4a5625a41118e3f057adf464e5925711ff231daa993e341fae50c88a451fcf85467619e39
6
+ metadata.gz: ee64a623c8968959f255c92b7b2060d0dd09ae63cc09d119e79ac13c98feededf583e90b464251311dccc4f0e1b57a39e26b1cc740770cd2af8b7034067133b9
7
+ data.tar.gz: 95275715a54c36b98c449e45f889e3533bd54ba9ccd9054afe7ca5f5f12171938c43235c3a9162ba42ca7d305509efcb504e1c95b03fc76acf797651d9928bea
@@ -1,3 +1,20 @@
1
+ ## Rails 5.1.2.rc1 (June 20, 2017) ##
2
+
3
+ * Restore previous behavior of collection proxies: their values can have
4
+ methods stubbed, and they respect extension modules applied by a default
5
+ scope.
6
+
7
+ *Ryuta Kamizono*
8
+
9
+ * Loading model schema from database is now thread-safe.
10
+
11
+ Fixes #28589.
12
+
13
+ *Vikrant Chaudhary*, *David Abdemoulaie*
14
+
15
+
16
+ ## Rails 5.1.1 (May 12, 2017) ##
17
+
1
18
  * Add type caster to `RuntimeReflection#alias_name`
2
19
 
3
20
  Fixes #28959.
@@ -1276,7 +1276,7 @@ module ActiveRecord
1276
1276
  # Scope examples:
1277
1277
  # has_many :comments, -> { where(author_id: 1) }
1278
1278
  # has_many :employees, -> { joins(:address) }
1279
- # has_many :posts, ->(post) { where("max_post_length > ?", post.length) }
1279
+ # has_many :posts, ->(blog) { where("max_post_length > ?", blog.max_post_length) }
1280
1280
  #
1281
1281
  # === Extensions
1282
1282
  #
@@ -1443,7 +1443,7 @@ module ActiveRecord
1443
1443
  # Scope examples:
1444
1444
  # has_one :author, -> { where(comment_id: 1) }
1445
1445
  # has_one :employer, -> { joins(:company) }
1446
- # has_one :dob, ->(dob) { where("Date.new(2000, 01, 01) > ?", dob) }
1446
+ # has_one :latest_post, ->(blog) { where("created_at > ?", blog.enabled_at) }
1447
1447
  #
1448
1448
  # === Options
1449
1449
  #
@@ -1573,7 +1573,7 @@ module ActiveRecord
1573
1573
  # Scope examples:
1574
1574
  # belongs_to :firm, -> { where(id: 2) }
1575
1575
  # belongs_to :user, -> { joins(:friends) }
1576
- # belongs_to :level, ->(level) { where("game_level > ?", level.current) }
1576
+ # belongs_to :level, ->(game) { where("game_level > ?", game.current_level) }
1577
1577
  #
1578
1578
  # === Options
1579
1579
  #
@@ -1769,9 +1769,8 @@ module ActiveRecord
1769
1769
  #
1770
1770
  # Scope examples:
1771
1771
  # has_and_belongs_to_many :projects, -> { includes(:milestones, :manager) }
1772
- # has_and_belongs_to_many :categories, ->(category) {
1773
- # where("default_category = ?", category.name)
1774
- # }
1772
+ # has_and_belongs_to_many :categories, ->(post) {
1773
+ # where("default_category = ?", post.default_category)
1775
1774
  #
1776
1775
  # === Extensions
1777
1776
  #
@@ -133,6 +133,16 @@ module ActiveRecord
133
133
  AssociationRelation.create(klass, klass.arel_table, klass.predicate_builder, self).merge!(klass.all)
134
134
  end
135
135
 
136
+ def extensions
137
+ extensions = klass.default_extensions | reflection.extensions
138
+
139
+ if scope = reflection.scope
140
+ extensions |= klass.unscoped.instance_exec(owner, &scope).extensions
141
+ end
142
+
143
+ extensions
144
+ end
145
+
136
146
  # Loads the \target if needed and returns it.
137
147
  #
138
148
  # This method is abstract in the sense that it relies on +find_target+,
@@ -24,7 +24,7 @@ module ActiveRecord
24
24
  alias_tracker = AliasTracker.create connection, association.klass.table_name, klass.type_caster
25
25
  chain_head, chain_tail = get_chain(reflection, association, alias_tracker)
26
26
 
27
- scope.extending! Array(reflection.options[:extend])
27
+ scope.extending! reflection.extensions
28
28
  add_constraints(scope, owner, reflection, chain_head, chain_tail)
29
29
  end
30
30
 
@@ -30,7 +30,8 @@ module ActiveRecord
30
30
  reload
31
31
  end
32
32
 
33
- CollectionProxy.create(klass, self)
33
+ @proxy ||= CollectionProxy.create(klass, self)
34
+ @proxy.reset_scope
34
35
  end
35
36
 
36
37
  # Implements the writer method, e.g. foo.items= for Foo.has_many :items
@@ -31,6 +31,9 @@ module ActiveRecord
31
31
  def initialize(klass, association) #:nodoc:
32
32
  @association = association
33
33
  super klass, klass.arel_table, klass.predicate_builder
34
+
35
+ extensions = association.extensions
36
+ extend(*extensions) if extensions.any?
34
37
  end
35
38
 
36
39
  def target
@@ -1088,9 +1091,8 @@ module ActiveRecord
1088
1091
  # person.pets(true) # fetches pets from the database
1089
1092
  # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
1090
1093
  def reload
1091
- @scope = nil
1092
1094
  proxy_association.reload
1093
- self
1095
+ reset_scope
1094
1096
  end
1095
1097
 
1096
1098
  # Unloads the association. Returns +self+.
@@ -1110,9 +1112,13 @@ module ActiveRecord
1110
1112
  # person.pets # fetches pets from the database
1111
1113
  # # => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
1112
1114
  def reset
1113
- @scope = nil
1114
1115
  proxy_association.reset
1115
1116
  proxy_association.reset_scope
1117
+ reset_scope
1118
+ end
1119
+
1120
+ def reset_scope # :nodoc:
1121
+ @scope = nil
1116
1122
  self
1117
1123
  end
1118
1124
 
@@ -1125,19 +1131,6 @@ module ActiveRecord
1125
1131
 
1126
1132
  delegate(*delegate_methods, to: :scope)
1127
1133
 
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
-
1141
1134
  private
1142
1135
 
1143
1136
  def find_nth_with_limit(index, limit)
@@ -1158,17 +1151,9 @@ module ActiveRecord
1158
1151
  @association.find_from_target?
1159
1152
  end
1160
1153
 
1161
- def association_scope
1162
- @association.association_scope
1163
- end
1164
-
1165
1154
  def exec_queries
1166
1155
  load_target
1167
1156
  end
1168
-
1169
- def respond_to_missing?(method, _)
1170
- association_scope.respond_to?(method) || super
1171
- end
1172
1157
  end
1173
1158
  end
1174
1159
  end
@@ -57,16 +57,12 @@ module ActiveRecord
57
57
  end
58
58
 
59
59
  module ClassMethods
60
- def define_method_attribute(attr_name)
61
- super
60
+ ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast id_was id_in_database).to_set
62
61
 
63
- if attr_name == primary_key && attr_name != "id"
64
- generated_attribute_methods.send(:alias_method, :id, primary_key)
65
- end
62
+ def instance_method_already_implemented?(method_name)
63
+ super || primary_key && ID_ATTRIBUTE_METHODS.include?(method_name)
66
64
  end
67
65
 
68
- ID_ATTRIBUTE_METHODS = %w(id id= id? id_before_type_cast id_was id_in_database).to_set
69
-
70
66
  def dangerous_attribute_method?(method_name)
71
67
  super && !ID_ATTRIBUTE_METHODS.include?(method_name)
72
68
  end
@@ -35,11 +35,15 @@ module ActiveRecord
35
35
  attr_name.to_s
36
36
  end
37
37
 
38
- write_attribute_with_type_cast(name, value, true)
38
+ name = self.class.primary_key if name == "id".freeze && self.class.primary_key
39
+ @attributes.write_from_user(name, value)
40
+ value
39
41
  end
40
42
 
41
43
  def raw_write_attribute(attr_name, value) # :nodoc:
42
- write_attribute_with_type_cast(attr_name, value, false)
44
+ name = attr_name.to_s
45
+ @attributes.write_cast_value(name, value)
46
+ value
43
47
  end
44
48
 
45
49
  private
@@ -47,19 +51,6 @@ module ActiveRecord
47
51
  def attribute=(attribute_name, value)
48
52
  write_attribute(attribute_name, value)
49
53
  end
50
-
51
- def write_attribute_with_type_cast(attr_name, value, should_type_cast)
52
- attr_name = attr_name.to_s
53
- attr_name = self.class.primary_key if attr_name == "id" && self.class.primary_key
54
-
55
- if should_type_cast
56
- @attributes.write_from_user(attr_name, value)
57
- else
58
- @attributes.write_cast_value(attr_name, value)
59
- end
60
-
61
- value
62
- end
63
54
  end
64
55
  end
65
56
  end
@@ -121,7 +121,7 @@ module ActiveRecord
121
121
  end
122
122
 
123
123
  def polymorphic_options
124
- as_options(polymorphic)
124
+ as_options(polymorphic).merge(null: options[:null])
125
125
  end
126
126
 
127
127
  def index_options
@@ -1000,7 +1000,7 @@ module ActiveRecord
1000
1000
 
1001
1001
  def dump_schema_information #:nodoc:
1002
1002
  versions = ActiveRecord::SchemaMigration.all_versions
1003
- insert_versions_sql(versions)
1003
+ insert_versions_sql(versions) if versions.any?
1004
1004
  end
1005
1005
 
1006
1006
  def insert_versions_sql(versions) # :nodoc:
@@ -13,15 +13,6 @@ module ActiveRecord
13
13
  result
14
14
  end
15
15
 
16
- # Returns an array of arrays containing the field values.
17
- # Order is the same as that returned by +columns+.
18
- def select_rows(arel, name = nil, binds = []) # :nodoc:
19
- select_result(arel, name, binds) do |result|
20
- @connection.next_result while @connection.more_results?
21
- result.to_a
22
- end
23
- end
24
-
25
16
  # Executes the SQL statement in the context of this connection.
26
17
  def execute(sql, name = nil)
27
18
  # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
@@ -58,16 +49,6 @@ module ActiveRecord
58
49
  @connection.last_id
59
50
  end
60
51
 
61
- def select_result(arel, name, binds)
62
- arel, binds = binds_from_relation(arel, binds)
63
- sql = to_sql(arel, binds)
64
- if without_prepared_statement?(binds)
65
- execute_and_free(sql, name) { |result| yield result }
66
- else
67
- exec_stmt_and_free(sql, name, binds, cache_stmt: true) { |_, result| yield result }
68
- end
69
- end
70
-
71
52
  def exec_stmt_and_free(sql, name, binds, cache_stmt: false)
72
53
  # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been
73
54
  # made since we established the connection
@@ -7,30 +7,6 @@ module ActiveRecord
7
7
  PostgreSQL::ExplainPrettyPrinter.new.pp(exec_query(sql, "EXPLAIN", binds))
8
8
  end
9
9
 
10
- def select_value(arel, name = nil, binds = []) # :nodoc:
11
- select_result(arel, name, binds) do |result|
12
- result.getvalue(0, 0) if result.ntuples > 0 && result.nfields > 0
13
- end
14
- end
15
-
16
- def select_values(arel, name = nil, binds = []) # :nodoc:
17
- select_result(arel, name, binds) do |result|
18
- if result.nfields > 0
19
- result.column_values(0)
20
- else
21
- []
22
- end
23
- end
24
- end
25
-
26
- # Executes a SELECT query and returns an array of rows. Each row is an
27
- # array of field values.
28
- def select_rows(arel, name = nil, binds = []) # :nodoc:
29
- select_result(arel, name, binds) do |result|
30
- result.values
31
- end
32
- end
33
-
34
10
  # The internal PostgreSQL identifier of the money data type.
35
11
  MONEY_COLUMN_TYPE_OID = 790 #:nodoc:
36
12
  # The internal PostgreSQL identifier of the BYTEA data type.
@@ -175,14 +151,6 @@ module ActiveRecord
175
151
  def suppress_composite_primary_key(pk)
176
152
  pk unless pk.is_a?(Array)
177
153
  end
178
-
179
- def select_result(arel, name, binds)
180
- arel, binds = binds_from_relation(arel, binds)
181
- sql = to_sql(arel, binds)
182
- execute_and_clear(sql, name, binds) do |result|
183
- yield result
184
- end
185
- end
186
154
  end
187
155
  end
188
156
  end
@@ -62,7 +62,7 @@ module ActiveRecord
62
62
  def quote_default_expression(value, column) # :nodoc:
63
63
  if value.is_a?(Proc)
64
64
  value.call
65
- elsif column.type == :uuid && value.include?("()")
65
+ elsif column.type == :uuid && /\(\)/.match?(value)
66
66
  value # Does not quote function default values for UUID columns
67
67
  elsif column.respond_to?(:array?)
68
68
  value = type_cast_from_column(column, value)
@@ -300,9 +300,17 @@ module ActiveRecord
300
300
 
301
301
  if pk && sequence
302
302
  quoted_sequence = quote_table_name(sequence)
303
+ max_pk = select_value("select MAX(#{quote_column_name pk}) from #{quote_table_name(table)}")
304
+ if max_pk.nil?
305
+ if postgresql_version >= 100000
306
+ minvalue = select_value("SELECT seqmin from pg_sequence where seqrelid = '#{quoted_sequence}'::regclass")
307
+ else
308
+ minvalue = select_value("SELECT min_value FROM #{quoted_sequence}")
309
+ end
310
+ end
303
311
 
304
312
  select_value(<<-end_sql, "SCHEMA")
305
- SELECT setval('#{quoted_sequence}', (SELECT COALESCE(MAX(#{quote_column_name pk})+(SELECT increment_by FROM #{quoted_sequence}), (SELECT min_value FROM #{quoted_sequence})) FROM #{quote_table_name(table)}), false)
313
+ SELECT setval('#{quoted_sequence}', #{max_pk ? max_pk : minvalue}, #{max_pk ? true : false})
306
314
  end_sql
307
315
  end
308
316
  end
@@ -7,8 +7,8 @@ module ActiveRecord
7
7
  module VERSION
8
8
  MAJOR = 5
9
9
  MINOR = 1
10
- TINY = 1
11
- PRE = nil
10
+ TINY = 2
11
+ PRE = "rc1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
@@ -1,3 +1,5 @@
1
+ require "monitor"
2
+
1
3
  module ActiveRecord
2
4
  module ModelSchema
3
5
  extend ActiveSupport::Concern
@@ -152,6 +154,8 @@ module ActiveRecord
152
154
  self.inheritance_column = "type"
153
155
 
154
156
  delegate :type_for_attribute, to: :class
157
+
158
+ initialize_load_schema_monitor
155
159
  end
156
160
 
157
161
  # Derives the join table name for +first_table+ and +second_table+. The
@@ -435,15 +439,31 @@ module ActiveRecord
435
439
  initialize_find_by_cache
436
440
  end
437
441
 
442
+ protected
443
+
444
+ def initialize_load_schema_monitor
445
+ @load_schema_monitor = Monitor.new
446
+ end
447
+
438
448
  private
439
449
 
450
+ def inherited(child_class)
451
+ super
452
+ child_class.initialize_load_schema_monitor
453
+ end
454
+
440
455
  def schema_loaded?
441
- defined?(@columns_hash) && @columns_hash
456
+ defined?(@schema_loaded) && @schema_loaded
442
457
  end
443
458
 
444
459
  def load_schema
445
- unless schema_loaded?
460
+ return if schema_loaded?
461
+ @load_schema_monitor.synchronize do
462
+ return if defined?(@columns_hash) && @columns_hash
463
+
446
464
  load_schema!
465
+
466
+ @schema_loaded = true
447
467
  end
448
468
  end
449
469
 
@@ -470,6 +490,7 @@ module ActiveRecord
470
490
  @attributes_builder = nil
471
491
  @columns = nil
472
492
  @columns_hash = nil
493
+ @schema_loaded = false
473
494
  @attribute_names = nil
474
495
  @yaml_encoder = nil
475
496
  direct_descendants.each do |descendant|
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  delegate :destroy, :destroy_all, :delete, :delete_all, :update, :update_all, to: :all
9
9
  delegate :find_each, :find_in_batches, :in_batches, to: :all
10
10
  delegate :select, :group, :order, :except, :reorder, :limit, :offset, :joins, :left_joins, :left_outer_joins, :or,
11
- :where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly,
11
+ :where, :rewhere, :preload, :eager_load, :includes, :from, :lock, :readonly, :extending,
12
12
  :having, :create_with, :distinct, :references, :none, :unscope, :merge, to: :all
13
13
  delegate :count, :average, :minimum, :maximum, :sum, :calculate, to: :all
14
14
  delegate :pluck, :ids, to: :all
@@ -199,7 +199,7 @@ module ActiveRecord
199
199
  def klass_join_scope(table, predicate_builder) # :nodoc:
200
200
  if klass.current_scope
201
201
  klass.current_scope.clone.tap { |scope|
202
- scope.joins_values = []
202
+ scope.joins_values = scope.left_outer_joins_values = [].freeze
203
203
  }
204
204
  else
205
205
  relation = ActiveRecord::Relation.create(
@@ -581,6 +581,10 @@ module ActiveRecord
581
581
  seed + [self]
582
582
  end
583
583
 
584
+ def extensions
585
+ Array(options[:extend])
586
+ end
587
+
584
588
  protected
585
589
 
586
590
  def actual_source_reflection # FIXME: this is a horrible name
@@ -30,14 +30,14 @@ module ActiveRecord
30
30
  # end
31
31
  #
32
32
  # ==== Options
33
- # * <tt>:batch_size</tt> - Specifies the size of the batch. Default to 1000.
33
+ # * <tt>:batch_size</tt> - Specifies the size of the batch. Defaults to 1000.
34
34
  # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
35
35
  # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
36
36
  # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
37
- # an order is present in the relation.
37
+ # an order is present in the relation.
38
38
  #
39
39
  # Limits are honored, and if present there is no requirement for the batch
40
- # size, it can be less than, equal, or greater than the limit.
40
+ # size: it can be less than, equal to, or greater than the limit.
41
41
  #
42
42
  # The options +start+ and +finish+ are especially useful if you want
43
43
  # multiple workers dealing with the same processing queue. You can make
@@ -89,14 +89,14 @@ module ActiveRecord
89
89
  # To be yielded each record one by one, use #find_each instead.
90
90
  #
91
91
  # ==== Options
92
- # * <tt>:batch_size</tt> - Specifies the size of the batch. Default to 1000.
92
+ # * <tt>:batch_size</tt> - Specifies the size of the batch. Defaults to 1000.
93
93
  # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
94
94
  # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
95
95
  # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
96
- # an order is present in the relation.
96
+ # an order is present in the relation.
97
97
  #
98
98
  # Limits are honored, and if present there is no requirement for the batch
99
- # size, it can be less than, equal, or greater than the limit.
99
+ # size: it can be less than, equal to, or greater than the limit.
100
100
  #
101
101
  # The options +start+ and +finish+ are especially useful if you want
102
102
  # multiple workers dealing with the same processing queue. You can make
@@ -140,9 +140,9 @@ module ActiveRecord
140
140
  # If you do not provide a block to #in_batches, it will return a
141
141
  # BatchEnumerator which is enumerable.
142
142
  #
143
- # Person.in_batches.with_index do |relation, batch_index|
143
+ # Person.in_batches.each_with_index do |relation, batch_index|
144
144
  # puts "Processing relation ##{batch_index}"
145
- # relation.each { |relation| relation.delete_all }
145
+ # relation.delete_all
146
146
  # end
147
147
  #
148
148
  # Examples of calling methods on the returned BatchEnumerator object:
@@ -152,12 +152,12 @@ module ActiveRecord
152
152
  # Person.in_batches.each_record(&:party_all_night!)
153
153
  #
154
154
  # ==== Options
155
- # * <tt>:of</tt> - Specifies the size of the batch. Default to 1000.
156
- # * <tt>:load</tt> - Specifies if the relation should be loaded. Default to false.
155
+ # * <tt>:of</tt> - Specifies the size of the batch. Defaults to 1000.
156
+ # * <tt>:load</tt> - Specifies if the relation should be loaded. Defaults to false.
157
157
  # * <tt>:start</tt> - Specifies the primary key value to start from, inclusive of the value.
158
158
  # * <tt>:finish</tt> - Specifies the primary key value to end at, inclusive of the value.
159
159
  # * <tt>:error_on_ignore</tt> - Overrides the application config to specify if an error should be raised when
160
- # an order is present in the relation.
160
+ # an order is present in the relation.
161
161
  #
162
162
  # Limits are honored, and if present there is no requirement for the batch
163
163
  # size, it can be less than, equal, or greater than the limit.
@@ -186,7 +186,7 @@ module ActiveRecord
186
186
  #
187
187
  # NOTE: It's not possible to set the order. That is automatically set to
188
188
  # ascending on the primary key ("id ASC") to make the batch ordering
189
- # consistent. Therefore the primary key must be orderable, e.g an integer
189
+ # consistent. Therefore the primary key must be orderable, e.g. an integer
190
190
  # or a string.
191
191
  #
192
192
  # NOTE: By its nature, batch processing is subject to race conditions if
@@ -25,8 +25,6 @@ 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
30
28
  super
31
29
  end
32
30
  end
@@ -110,7 +110,11 @@ module ActiveRecord
110
110
 
111
111
  if default_scope_override
112
112
  # The user has defined their own default scope method, so call that
113
- evaluate_default_scope { default_scope }
113
+ evaluate_default_scope do
114
+ if scope = default_scope
115
+ (base_rel ||= relation).merge(scope)
116
+ end
117
+ end
114
118
  elsif default_scopes.any?
115
119
  base_rel ||= relation
116
120
  evaluate_default_scope do
@@ -30,12 +30,15 @@ module ActiveRecord
30
30
  end
31
31
 
32
32
  def default_scoped # :nodoc:
33
- scope = build_default_scope
33
+ scope = relation
34
+ build_default_scope(scope) || scope
35
+ end
34
36
 
35
- if scope
36
- relation.spawn.merge!(scope)
37
+ def default_extensions # :nodoc:
38
+ if scope = current_scope || build_default_scope
39
+ scope.extensions
37
40
  else
38
- relation
41
+ []
39
42
  end
40
43
  end
41
44
 
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.1
4
+ version: 5.1.2.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-05-12 00:00:00.000000000 Z
11
+ date: 2017-06-20 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.1
19
+ version: 5.1.2.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.1
26
+ version: 5.1.2.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.1
33
+ version: 5.1.2.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.1
40
+ version: 5.1.2.rc1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -333,14 +333,13 @@ 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: '0'
338
+ version: 1.3.1
339
339
  requirements: []
340
340
  rubyforge_project:
341
- rubygems_version: 2.6.10
341
+ rubygems_version: 2.6.12
342
342
  signing_key:
343
343
  specification_version: 4
344
344
  summary: Object-relational mapper framework (part of Rails).
345
345
  test_files: []
346
- has_rdoc: