activerecord 5.2.3 → 5.2.4.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 +40 -0
- data/lib/active_record/associations/builder/collection_association.rb +2 -2
- data/lib/active_record/associations/has_many_through_association.rb +4 -11
- data/lib/active_record/associations/join_dependency/join_association.rb +28 -7
- data/lib/active_record/associations/preloader.rb +1 -1
- data/lib/active_record/autosave_association.rb +20 -6
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +22 -3
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +3 -3
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +1 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +2 -2
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/reflection.rb +10 -14
- data/lib/active_record/relation/calculations.rb +5 -4
- data/lib/active_record/relation/finder_methods.rb +1 -1
- data/lib/active_record/relation/query_methods.rb +17 -15
- data/lib/active_record/scoping/default.rb +2 -2
- data/lib/active_record/statement_cache.rb +2 -2
- data/lib/active_record/transactions.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b4acfd92192be68808412ee4173cb2f23ef4ff481ce4dbada24e371479c6930
|
4
|
+
data.tar.gz: a0e874d39c850fe5b94959675e33292dd450d51ae1b6e5f284b53d64e38b291a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9af7a4f18ed98175bb075dc09be0bd49724f941c5fdbc2c5a01cefa097f76695efb2d42f3c955ae81c5293b6e0f88fc0933ae8b9dbab9cc8e18f039346d8c874
|
7
|
+
data.tar.gz: 2338d1699634c205907b8cdb2507917af2d2b990c5a236a0c3fd53fa52162e1b34314140bb4b038c11b9554ed9e6ad500d779334c720e2c9bd95bd5d77fcf1b9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
## Rails 5.2.4.rc1 (November 22, 2019) ##
|
2
|
+
|
3
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
4
|
+
|
5
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
6
|
+
associations, the callback for a `has_many` association was run while
|
7
|
+
another instance of the same callback on the same association hadn't
|
8
|
+
finished running. When control returned to the first instance of the
|
9
|
+
callback, the instance variable had changed, and subsequent associated
|
10
|
+
records weren't saved correctly. Specifically, the ID field for the
|
11
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
12
|
+
|
13
|
+
Fixes #28080.
|
14
|
+
|
15
|
+
*Larry Reid*
|
16
|
+
|
17
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
18
|
+
|
19
|
+
Fixes #36022.
|
20
|
+
|
21
|
+
*Ryuta Kamizono*
|
22
|
+
|
23
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
24
|
+
|
25
|
+
*Martin R. Schuster*
|
26
|
+
|
27
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
28
|
+
|
29
|
+
Fixes #36465.
|
30
|
+
|
31
|
+
*Jeff Doering*
|
32
|
+
|
33
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
34
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
35
|
+
|
36
|
+
Fixes #33249.
|
37
|
+
|
38
|
+
*Ryan H. Kerr*
|
39
|
+
|
40
|
+
|
1
41
|
## Rails 5.2.3 (March 27, 2019) ##
|
2
42
|
|
3
43
|
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
@@ -20,10 +20,10 @@ module ActiveRecord::Associations::Builder # :nodoc:
|
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.define_extensions(model, name)
|
23
|
+
def self.define_extensions(model, name, &block)
|
24
24
|
if block_given?
|
25
25
|
extension_module_name = "#{model.name.demodulize}#{name.to_s.camelize}AssociationExtension"
|
26
|
-
extension = Module.new(&
|
26
|
+
extension = Module.new(&block)
|
27
27
|
model.parent.const_set(extension_module_name, extension)
|
28
28
|
end
|
29
29
|
end
|
@@ -57,21 +57,14 @@ module ActiveRecord
|
|
57
57
|
@through_records[record.object_id] ||= begin
|
58
58
|
ensure_mutable
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
attributes = through_scope_attributes
|
61
|
+
attributes[source_reflection.name] = record
|
62
|
+
attributes[source_reflection.foreign_type] = options[:source_type] if options[:source_type]
|
62
63
|
|
63
|
-
|
64
|
-
through_record.send("#{source_reflection.foreign_type}=", options[:source_type])
|
65
|
-
end
|
66
|
-
|
67
|
-
through_record
|
64
|
+
through_association.build(attributes)
|
68
65
|
end
|
69
66
|
end
|
70
67
|
|
71
|
-
def options_for_through_record
|
72
|
-
[through_scope_attributes]
|
73
|
-
end
|
74
|
-
|
75
68
|
def through_scope_attributes
|
76
69
|
scope.where_values_hash(through_association.reflection.name.to_s).
|
77
70
|
except!(through_association.reflection.foreign_key,
|
@@ -30,17 +30,21 @@ module ActiveRecord
|
|
30
30
|
table = tables[-i]
|
31
31
|
klass = reflection.klass
|
32
32
|
|
33
|
-
|
33
|
+
join_scope = reflection.join_scope(table, foreign_table, foreign_klass)
|
34
34
|
|
35
|
-
joins << table.create_join(table, table.create_on(constraint), join_type)
|
36
|
-
|
37
|
-
join_scope = reflection.join_scope(table, foreign_klass)
|
38
35
|
arel = join_scope.arel(alias_tracker.aliases)
|
36
|
+
nodes = arel.constraints.first
|
37
|
+
|
38
|
+
others, children = nodes.children.partition do |node|
|
39
|
+
!fetch_arel_attribute(node) { |attr| attr.relation.name == table.name }
|
40
|
+
end
|
41
|
+
nodes = table.create_and(children)
|
39
42
|
|
40
|
-
|
43
|
+
joins << table.create_join(table, table.create_on(nodes), join_type)
|
44
|
+
|
45
|
+
unless others.empty?
|
41
46
|
joins.concat arel.join_sources
|
42
|
-
|
43
|
-
right.expr = right.expr.and(arel.constraints)
|
47
|
+
append_constraints(joins.last, others)
|
44
48
|
end
|
45
49
|
|
46
50
|
# The current table in this iteration becomes the foreign table in the next
|
@@ -54,6 +58,23 @@ module ActiveRecord
|
|
54
58
|
@tables = tables
|
55
59
|
@table = tables.first
|
56
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def fetch_arel_attribute(value)
|
64
|
+
case value
|
65
|
+
when Arel::Nodes::Between, Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual, Arel::Nodes::LessThan, Arel::Nodes::LessThanOrEqual, Arel::Nodes::GreaterThan, Arel::Nodes::GreaterThanOrEqual
|
66
|
+
yield value.left.is_a?(Arel::Attributes::Attribute) ? value.left : value.right
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def append_constraints(join, constraints)
|
71
|
+
if join.is_a?(Arel::Nodes::StringJoin)
|
72
|
+
join_string = table.create_and(constraints.unshift(join.left))
|
73
|
+
join.left = Arel.sql(base_klass.connection.visitor.compile(join_string))
|
74
|
+
else
|
75
|
+
join.right.expr.children.concat(constraints)
|
76
|
+
end
|
77
|
+
end
|
57
78
|
end
|
58
79
|
end
|
59
80
|
end
|
@@ -177,7 +177,7 @@ module ActiveRecord
|
|
177
177
|
# and attach it to a relation. The class returned implements a `run` method
|
178
178
|
# that accepts a preloader.
|
179
179
|
def preloader_for(reflection, owners)
|
180
|
-
if owners.
|
180
|
+
if owners.all? { |o| o.association(reflection.name).loaded? }
|
181
181
|
return AlreadyLoaded
|
182
182
|
end
|
183
183
|
reflection.check_preloadable!
|
@@ -272,7 +272,7 @@ module ActiveRecord
|
|
272
272
|
# or saved. If +autosave+ is +false+ only new records will be returned,
|
273
273
|
# unless the parent is/was a new record itself.
|
274
274
|
def associated_records_to_validate_or_save(association, new_record, autosave)
|
275
|
-
if new_record
|
275
|
+
if new_record || custom_validation_context?
|
276
276
|
association && association.target
|
277
277
|
elsif autosave
|
278
278
|
association.target.find_all(&:changed_for_autosave?)
|
@@ -304,7 +304,7 @@ module ActiveRecord
|
|
304
304
|
def validate_single_association(reflection)
|
305
305
|
association = association_instance_get(reflection.name)
|
306
306
|
record = association && association.reader
|
307
|
-
association_valid?(reflection, record) if record
|
307
|
+
association_valid?(reflection, record) if record && (record.changed_for_autosave? || custom_validation_context?)
|
308
308
|
end
|
309
309
|
|
310
310
|
# Validate the associated records if <tt>:validate</tt> or
|
@@ -324,7 +324,7 @@ module ActiveRecord
|
|
324
324
|
def association_valid?(reflection, record, index = nil)
|
325
325
|
return true if record.destroyed? || (reflection.options[:autosave] && record.marked_for_destruction?)
|
326
326
|
|
327
|
-
context = validation_context
|
327
|
+
context = validation_context if custom_validation_context?
|
328
328
|
|
329
329
|
unless valid = record.valid?(context)
|
330
330
|
if reflection.options[:autosave]
|
@@ -382,10 +382,14 @@ module ActiveRecord
|
|
382
382
|
if association = association_instance_get(reflection.name)
|
383
383
|
autosave = reflection.options[:autosave]
|
384
384
|
|
385
|
+
# By saving the instance variable in a local variable,
|
386
|
+
# we make the whole callback re-entrant.
|
387
|
+
new_record_before_save = @new_record_before_save
|
388
|
+
|
385
389
|
# reconstruct the scope now that we know the owner's id
|
386
390
|
association.reset_scope
|
387
391
|
|
388
|
-
if records = associated_records_to_validate_or_save(association,
|
392
|
+
if records = associated_records_to_validate_or_save(association, new_record_before_save, autosave)
|
389
393
|
if autosave
|
390
394
|
records_to_destroy = records.select(&:marked_for_destruction?)
|
391
395
|
records_to_destroy.each { |record| association.destroy(record) }
|
@@ -397,7 +401,7 @@ module ActiveRecord
|
|
397
401
|
|
398
402
|
saved = true
|
399
403
|
|
400
|
-
if autosave != false && (
|
404
|
+
if autosave != false && (new_record_before_save || record.new_record?)
|
401
405
|
if autosave
|
402
406
|
saved = association.insert_record(record, false)
|
403
407
|
elsif !reflection.nested?
|
@@ -457,10 +461,16 @@ module ActiveRecord
|
|
457
461
|
# If the record is new or it has changed, returns true.
|
458
462
|
def record_changed?(reflection, record, key)
|
459
463
|
record.new_record? ||
|
460
|
-
|
464
|
+
association_foreign_key_changed?(reflection, record, key) ||
|
461
465
|
record.will_save_change_to_attribute?(reflection.foreign_key)
|
462
466
|
end
|
463
467
|
|
468
|
+
def association_foreign_key_changed?(reflection, record, key)
|
469
|
+
return false if reflection.through_reflection?
|
470
|
+
|
471
|
+
record.has_attribute?(reflection.foreign_key) && record[reflection.foreign_key] != key
|
472
|
+
end
|
473
|
+
|
464
474
|
# Saves the associated record if it's new or <tt>:autosave</tt> is enabled.
|
465
475
|
#
|
466
476
|
# In addition, it will destroy the association if it was marked for destruction.
|
@@ -489,6 +499,10 @@ module ActiveRecord
|
|
489
499
|
end
|
490
500
|
end
|
491
501
|
|
502
|
+
def custom_validation_context?
|
503
|
+
validation_context && [:create, :update].exclude?(validation_context)
|
504
|
+
end
|
505
|
+
|
492
506
|
def _ensure_no_duplicate_errors
|
493
507
|
errors.messages.each_key do |attribute|
|
494
508
|
errors[attribute].uniq!
|
@@ -310,7 +310,7 @@ module ActiveRecord
|
|
310
310
|
include QueryCache::ConnectionPoolConfiguration
|
311
311
|
|
312
312
|
attr_accessor :automatic_reconnect, :checkout_timeout, :schema_cache
|
313
|
-
attr_reader :spec, :
|
313
|
+
attr_reader :spec, :size, :reaper
|
314
314
|
|
315
315
|
# Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification
|
316
316
|
# object which describes database connection information (e.g. adapter,
|
@@ -379,7 +379,7 @@ module ActiveRecord
|
|
379
379
|
# #connection can be called any number of times; the connection is
|
380
380
|
# held in a cache keyed by a thread.
|
381
381
|
def connection
|
382
|
-
@thread_cached_conns[connection_cache_key(
|
382
|
+
@thread_cached_conns[connection_cache_key(current_thread)] ||= checkout
|
383
383
|
end
|
384
384
|
|
385
385
|
# Returns true if there is an open connection being used for the current thread.
|
@@ -388,7 +388,7 @@ module ActiveRecord
|
|
388
388
|
# #connection or #with_connection methods. Connections obtained through
|
389
389
|
# #checkout will not be detected by #active_connection?
|
390
390
|
def active_connection?
|
391
|
-
@thread_cached_conns[connection_cache_key(
|
391
|
+
@thread_cached_conns[connection_cache_key(current_thread)]
|
392
392
|
end
|
393
393
|
|
394
394
|
# Signal that the thread is finished with the current connection.
|
@@ -423,6 +423,21 @@ module ActiveRecord
|
|
423
423
|
synchronize { @connections.any? }
|
424
424
|
end
|
425
425
|
|
426
|
+
# Returns an array containing the connections currently in the pool.
|
427
|
+
# Access to the array does not require synchronization on the pool because
|
428
|
+
# the array is newly created and not retained by the pool.
|
429
|
+
#
|
430
|
+
# However; this method bypasses the ConnectionPool's thread-safe connection
|
431
|
+
# access pattern. A returned connection may be owned by another thread,
|
432
|
+
# unowned, or by happen-stance owned by the calling thread.
|
433
|
+
#
|
434
|
+
# Calling methods on a connection without ownership is subject to the
|
435
|
+
# thread-safety guarantees of the underlying method. Many of the methods
|
436
|
+
# on connection adapter classes are inherently multi-thread unsafe.
|
437
|
+
def connections
|
438
|
+
synchronize { @connections.dup }
|
439
|
+
end
|
440
|
+
|
426
441
|
# Disconnects all connections in the pool, and clears the pool.
|
427
442
|
#
|
428
443
|
# Raises:
|
@@ -668,6 +683,10 @@ module ActiveRecord
|
|
668
683
|
thread
|
669
684
|
end
|
670
685
|
|
686
|
+
def current_thread
|
687
|
+
@lock_thread || Thread.current
|
688
|
+
end
|
689
|
+
|
671
690
|
# Take control of all existing connections so a "group" action such as
|
672
691
|
# reload/disconnect can be performed safely. It is no longer enough to
|
673
692
|
# wrap it in +synchronize+ because some pool's actions are allowed
|
@@ -32,17 +32,17 @@ module ActiveRecord
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def enable_query_cache!
|
35
|
-
@query_cache_enabled[connection_cache_key(
|
35
|
+
@query_cache_enabled[connection_cache_key(current_thread)] = true
|
36
36
|
connection.enable_query_cache! if active_connection?
|
37
37
|
end
|
38
38
|
|
39
39
|
def disable_query_cache!
|
40
|
-
@query_cache_enabled.delete connection_cache_key(
|
40
|
+
@query_cache_enabled.delete connection_cache_key(current_thread)
|
41
41
|
connection.disable_query_cache! if active_connection?
|
42
42
|
end
|
43
43
|
|
44
44
|
def query_cache_enabled
|
45
|
-
@query_cache_enabled[connection_cache_key(
|
45
|
+
@query_cache_enabled[connection_cache_key(current_thread)]
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -100,7 +100,7 @@ module ActiveRecord
|
|
100
100
|
def index_exists?(table_name, column_name, options = {})
|
101
101
|
column_names = Array(column_name).map(&:to_s)
|
102
102
|
checks = []
|
103
|
-
checks << lambda { |i| i.columns == column_names }
|
103
|
+
checks << lambda { |i| Array(i.columns) == column_names }
|
104
104
|
checks << lambda { |i| i.unique } if options[:unique]
|
105
105
|
checks << lambda { |i| i.name == options[:name].to_s } if options[:name]
|
106
106
|
|
@@ -525,9 +525,9 @@ module ActiveRecord
|
|
525
525
|
result = exec_query(sql, "SCHEMA").first
|
526
526
|
|
527
527
|
if result
|
528
|
-
# Splitting with left parentheses and
|
528
|
+
# Splitting with left parentheses and discarding the first part will return all
|
529
529
|
# columns separated with comma(,).
|
530
|
-
columns_string = result["sql"].split("(").last
|
530
|
+
columns_string = result["sql"].split("(", 2).last
|
531
531
|
|
532
532
|
columns_string.split(",").each do |column_string|
|
533
533
|
# This regex will match the column name and collation type and will save
|
@@ -174,28 +174,24 @@ module ActiveRecord
|
|
174
174
|
scope ? [scope] : []
|
175
175
|
end
|
176
176
|
|
177
|
-
def
|
178
|
-
key = join_keys.key
|
179
|
-
foreign_key = join_keys.foreign_key
|
180
|
-
|
181
|
-
constraint = table[key].eq(foreign_table[foreign_key])
|
182
|
-
|
183
|
-
if klass.finder_needs_type_condition?
|
184
|
-
table.create_and([constraint, klass.send(:type_condition, table)])
|
185
|
-
else
|
186
|
-
constraint
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
def join_scope(table, foreign_klass)
|
177
|
+
def join_scope(table, foreign_table, foreign_klass)
|
191
178
|
predicate_builder = predicate_builder(table)
|
192
179
|
scope_chain_items = join_scopes(table, predicate_builder)
|
193
180
|
klass_scope = klass_join_scope(table, predicate_builder)
|
194
181
|
|
182
|
+
key = join_keys.key
|
183
|
+
foreign_key = join_keys.foreign_key
|
184
|
+
|
185
|
+
klass_scope.where!(table[key].eq(foreign_table[foreign_key]))
|
186
|
+
|
195
187
|
if type
|
196
188
|
klass_scope.where!(type => foreign_klass.polymorphic_name)
|
197
189
|
end
|
198
190
|
|
191
|
+
if klass.finder_needs_type_condition?
|
192
|
+
klass_scope.where!(klass.send(:type_condition, table))
|
193
|
+
end
|
194
|
+
|
199
195
|
scope_chain_items.inject(klass_scope, &:merge!)
|
200
196
|
end
|
201
197
|
|
@@ -133,11 +133,12 @@ module ActiveRecord
|
|
133
133
|
relation = apply_join_dependency
|
134
134
|
|
135
135
|
if operation.to_s.downcase == "count"
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
relation.order_values = []
|
136
|
+
unless distinct_value || distinct_select?(column_name || select_for_count)
|
137
|
+
relation.distinct!
|
138
|
+
relation.select_values = [ klass.primary_key || table[Arel.star] ]
|
140
139
|
end
|
140
|
+
# PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT
|
141
|
+
relation.order_values = []
|
141
142
|
end
|
142
143
|
|
143
144
|
relation.calculate(operation, column_name)
|
@@ -360,7 +360,7 @@ module ActiveRecord
|
|
360
360
|
|
361
361
|
def construct_relation_for_exists(conditions)
|
362
362
|
if distinct_value && offset_value
|
363
|
-
relation = limit(1)
|
363
|
+
relation = except(:order).limit!(1)
|
364
364
|
else
|
365
365
|
relation = except(:select, :distinct, :order)._select!(ONE_AS_ONE).limit!(1)
|
366
366
|
end
|
@@ -232,9 +232,6 @@ module ActiveRecord
|
|
232
232
|
|
233
233
|
def _select!(*fields) # :nodoc:
|
234
234
|
fields.flatten!
|
235
|
-
fields.map! do |field|
|
236
|
-
klass.attribute_alias?(field) ? klass.attribute_alias(field).to_sym : field
|
237
|
-
end
|
238
235
|
self.select_values += fields
|
239
236
|
self
|
240
237
|
end
|
@@ -1053,10 +1050,11 @@ module ActiveRecord
|
|
1053
1050
|
columns.flat_map do |field|
|
1054
1051
|
case field
|
1055
1052
|
when Symbol
|
1056
|
-
field
|
1057
|
-
|
1053
|
+
arel_column(field.to_s) do |attr_name|
|
1054
|
+
connection.quote_table_name(attr_name)
|
1055
|
+
end
|
1058
1056
|
when String
|
1059
|
-
arel_column(field)
|
1057
|
+
arel_column(field, &:itself)
|
1060
1058
|
when Proc
|
1061
1059
|
field.call
|
1062
1060
|
else
|
@@ -1072,7 +1070,7 @@ module ActiveRecord
|
|
1072
1070
|
if klass.columns_hash.key?(field) && (!from || table_name_matches?(from))
|
1073
1071
|
arel_attribute(field)
|
1074
1072
|
else
|
1075
|
-
yield
|
1073
|
+
yield field
|
1076
1074
|
end
|
1077
1075
|
end
|
1078
1076
|
|
@@ -1161,20 +1159,14 @@ module ActiveRecord
|
|
1161
1159
|
order_args.map! do |arg|
|
1162
1160
|
case arg
|
1163
1161
|
when Symbol
|
1164
|
-
arg
|
1165
|
-
arel_column(arg) {
|
1166
|
-
Arel.sql(connection.quote_table_name(arg))
|
1167
|
-
}.asc
|
1162
|
+
order_column(arg.to_s).asc
|
1168
1163
|
when Hash
|
1169
1164
|
arg.map { |field, dir|
|
1170
1165
|
case field
|
1171
1166
|
when Arel::Nodes::SqlLiteral
|
1172
1167
|
field.send(dir.downcase)
|
1173
1168
|
else
|
1174
|
-
field
|
1175
|
-
arel_column(field) {
|
1176
|
-
Arel.sql(connection.quote_table_name(field))
|
1177
|
-
}.send(dir.downcase)
|
1169
|
+
order_column(field.to_s).send(dir.downcase)
|
1178
1170
|
end
|
1179
1171
|
}
|
1180
1172
|
else
|
@@ -1183,6 +1175,16 @@ module ActiveRecord
|
|
1183
1175
|
end.flatten!
|
1184
1176
|
end
|
1185
1177
|
|
1178
|
+
def order_column(field)
|
1179
|
+
arel_column(field) do |attr_name|
|
1180
|
+
if attr_name == "count" && !group_values.empty?
|
1181
|
+
arel_attribute(attr_name)
|
1182
|
+
else
|
1183
|
+
Arel.sql(connection.quote_table_name(attr_name))
|
1184
|
+
end
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
|
1186
1188
|
# Checks to make sure that the arguments are not blank. Note that if some
|
1187
1189
|
# blank-like object were initially passed into the query method, then this
|
1188
1190
|
# method will not raise an error.
|
@@ -86,8 +86,8 @@ module ActiveRecord
|
|
86
86
|
# # Should return a scope, you can call 'super' here etc.
|
87
87
|
# end
|
88
88
|
# end
|
89
|
-
def default_scope(scope = nil) # :doc:
|
90
|
-
scope =
|
89
|
+
def default_scope(scope = nil, &block) # :doc:
|
90
|
+
scope = block if block_given?
|
91
91
|
|
92
92
|
if scope.is_a?(Relation) || !scope.respond_to?(:call)
|
93
93
|
raise ArgumentError,
|
@@ -87,8 +87,8 @@ module ActiveRecord
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
def self.create(connection,
|
91
|
-
relation = block.call Params.new
|
90
|
+
def self.create(connection, callable = nil, &block)
|
91
|
+
relation = (callable || block).call Params.new
|
92
92
|
query_builder, binds = connection.cacheable_query(self, relation.arel)
|
93
93
|
bind_map = BindMap.new(binds)
|
94
94
|
new(query_builder, bind_map, relation.klass)
|
@@ -340,6 +340,7 @@ module ActiveRecord
|
|
340
340
|
# Ensure that it is not called if the object was never persisted (failed create),
|
341
341
|
# but call it after the commit of a destroyed object.
|
342
342
|
def committed!(should_run_callbacks: true) #:nodoc:
|
343
|
+
force_clear_transaction_record_state
|
343
344
|
if should_run_callbacks && (destroyed? || persisted?)
|
344
345
|
@_committed_already_called = true
|
345
346
|
_run_commit_without_transaction_enrollment_callbacks
|
@@ -347,7 +348,6 @@ module ActiveRecord
|
|
347
348
|
end
|
348
349
|
ensure
|
349
350
|
@_committed_already_called = false
|
350
|
-
force_clear_transaction_record_state
|
351
351
|
end
|
352
352
|
|
353
353
|
# Call the #after_rollback callbacks. The +force_restore_state+ argument indicates if the record
|
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.2.
|
4
|
+
version: 5.2.4.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: 2019-
|
11
|
+
date: 2019-11-23 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.2.
|
19
|
+
version: 5.2.4.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.2.
|
26
|
+
version: 5.2.4.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.2.
|
33
|
+
version: 5.2.4.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.2.
|
40
|
+
version: 5.2.4.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -307,8 +307,8 @@ homepage: http://rubyonrails.org
|
|
307
307
|
licenses:
|
308
308
|
- MIT
|
309
309
|
metadata:
|
310
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.
|
311
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.
|
310
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.4.rc1/activerecord
|
311
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.4.rc1/activerecord/CHANGELOG.md
|
312
312
|
post_install_message:
|
313
313
|
rdoc_options:
|
314
314
|
- "--main"
|
@@ -322,11 +322,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
322
322
|
version: 2.2.2
|
323
323
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
324
324
|
requirements:
|
325
|
-
- - "
|
325
|
+
- - ">"
|
326
326
|
- !ruby/object:Gem::Version
|
327
|
-
version:
|
327
|
+
version: 1.3.1
|
328
328
|
requirements: []
|
329
|
-
rubygems_version: 3.0.
|
329
|
+
rubygems_version: 3.0.3
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
332
|
summary: Object-relational mapper framework (part of Rails).
|