activerecord 5.2.0.rc1 → 5.2.0.rc2
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 +75 -16
- data/README.rdoc +1 -1
- data/lib/active_record/associations/association.rb +4 -4
- data/lib/active_record/associations/association_scope.rb +6 -6
- data/lib/active_record/associations/belongs_to_association.rb +9 -1
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +1 -1
- data/lib/active_record/associations/has_one_association.rb +1 -0
- data/lib/active_record/associations/join_dependency.rb +2 -4
- data/lib/active_record/associations/preloader/association.rb +1 -1
- data/lib/active_record/attribute_assignment.rb +0 -5
- data/lib/active_record/attribute_methods.rb +19 -14
- data/lib/active_record/attribute_methods/dirty.rb +4 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +1 -1
- data/lib/active_record/connection_adapters/abstract_adapter.rb +2 -2
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid.rb +1 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +2 -1
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +1 -1
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/inheritance.rb +40 -10
- data/lib/active_record/locking/optimistic.rb +27 -41
- data/lib/active_record/migration.rb +8 -2
- data/lib/active_record/model_schema.rb +1 -0
- data/lib/active_record/persistence.rb +60 -51
- data/lib/active_record/query_cache.rb +6 -6
- data/lib/active_record/railties/databases.rake +1 -1
- data/lib/active_record/reflection.rb +7 -4
- data/lib/active_record/relation/calculations.rb +1 -1
- data/lib/active_record/relation/finder_methods.rb +3 -3
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +7 -5
- data/lib/active_record/relation/predicate_builder/range_handler.rb +4 -3
- data/lib/active_record/relation/query_attribute.rb +17 -0
- data/lib/active_record/validations/uniqueness.rb +1 -1
- metadata +10 -9
@@ -7,20 +7,20 @@ module ActiveRecord
|
|
7
7
|
# Enable the query cache within the block if Active Record is configured.
|
8
8
|
# If it's not, it will execute the given block.
|
9
9
|
def cache(&block)
|
10
|
-
if configurations.empty?
|
11
|
-
yield
|
12
|
-
else
|
10
|
+
if connected? || !configurations.empty?
|
13
11
|
connection.cache(&block)
|
12
|
+
else
|
13
|
+
yield
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
# Disable the query cache within the block if Active Record is configured.
|
18
18
|
# If it's not, it will execute the given block.
|
19
19
|
def uncached(&block)
|
20
|
-
if configurations.empty?
|
21
|
-
yield
|
22
|
-
else
|
20
|
+
if connected? || !configurations.empty?
|
23
21
|
connection.uncached(&block)
|
22
|
+
else
|
23
|
+
yield
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -229,7 +229,7 @@ db_namespace = namespace :db do
|
|
229
229
|
base_dir = ActiveRecord::Tasks::DatabaseTasks.fixtures_path
|
230
230
|
|
231
231
|
Dir["#{base_dir}/**/*.yml"].each do |file|
|
232
|
-
if data = YAML
|
232
|
+
if data = YAML.load(ERB.new(IO.read(file)).result)
|
233
233
|
data.each_key do |key|
|
234
234
|
key_id = ActiveRecord::FixtureSet.identify(key)
|
235
235
|
|
@@ -193,7 +193,7 @@ module ActiveRecord
|
|
193
193
|
klass_scope = klass_join_scope(table, predicate_builder)
|
194
194
|
|
195
195
|
if type
|
196
|
-
klass_scope.where!(type => foreign_klass.
|
196
|
+
klass_scope.where!(type => foreign_klass.polymorphic_name)
|
197
197
|
end
|
198
198
|
|
199
199
|
scope_chain_items.inject(klass_scope, &:merge!)
|
@@ -416,6 +416,9 @@ module ActiveRecord
|
|
416
416
|
# Active Record class.
|
417
417
|
class AssociationReflection < MacroReflection #:nodoc:
|
418
418
|
def compute_class(name)
|
419
|
+
if polymorphic?
|
420
|
+
raise ArgumentError, "Polymorphic association does not support to compute class."
|
421
|
+
end
|
419
422
|
active_record.send(:compute_type, name)
|
420
423
|
end
|
421
424
|
|
@@ -626,9 +629,6 @@ module ActiveRecord
|
|
626
629
|
# +automatic_inverse_of+ method is a valid reflection. We must
|
627
630
|
# make sure that the reflection's active_record name matches up
|
628
631
|
# with the current reflection's klass name.
|
629
|
-
#
|
630
|
-
# Note: klass will always be valid because when there's a NameError
|
631
|
-
# from calling +klass+, +reflection+ will already be set to false.
|
632
632
|
def valid_inverse_reflection?(reflection)
|
633
633
|
reflection &&
|
634
634
|
klass <= reflection.active_record &&
|
@@ -732,6 +732,9 @@ module ActiveRecord
|
|
732
732
|
end
|
733
733
|
|
734
734
|
private
|
735
|
+
def can_find_inverse_of_automatically?(_)
|
736
|
+
!polymorphic? && super
|
737
|
+
end
|
735
738
|
|
736
739
|
def calculate_constructable(macro, options)
|
737
740
|
!polymorphic?
|
@@ -132,7 +132,7 @@ module ActiveRecord
|
|
132
132
|
if has_include?(column_name)
|
133
133
|
relation = apply_join_dependency
|
134
134
|
|
135
|
-
if operation.to_s.downcase == "count"
|
135
|
+
if operation.to_s.downcase == "count"
|
136
136
|
relation.distinct!
|
137
137
|
# PostgreSQL: ORDER BY expressions must appear in SELECT list when using DISTINCT
|
138
138
|
if (column_name == :all || column_name.nil?) && select_values.empty?
|
@@ -371,16 +371,16 @@ module ActiveRecord
|
|
371
371
|
relation
|
372
372
|
end
|
373
373
|
|
374
|
-
def construct_join_dependency
|
374
|
+
def construct_join_dependency
|
375
375
|
including = eager_load_values + includes_values
|
376
376
|
joins = joins_values.select { |join| join.is_a?(Arel::Nodes::Join) }
|
377
377
|
ActiveRecord::Associations::JoinDependency.new(
|
378
|
-
klass, table, including, alias_tracker(joins)
|
378
|
+
klass, table, including, alias_tracker(joins)
|
379
379
|
)
|
380
380
|
end
|
381
381
|
|
382
382
|
def apply_join_dependency(eager_loading: true)
|
383
|
-
join_dependency = construct_join_dependency
|
383
|
+
join_dependency = construct_join_dependency
|
384
384
|
relation = except(:includes, :eager_load, :preload).joins!(join_dependency)
|
385
385
|
|
386
386
|
if eager_loading && !using_limitable_reflections?(join_dependency.reflections)
|
@@ -25,19 +25,21 @@ module ActiveRecord
|
|
25
25
|
private
|
26
26
|
def type_to_ids_mapping
|
27
27
|
default_hash = Hash.new { |hsh, key| hsh[key] = [] }
|
28
|
-
values.each_with_object(default_hash)
|
28
|
+
values.each_with_object(default_hash) do |value, hash|
|
29
|
+
hash[klass(value).polymorphic_name] << convert_to_id(value)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
|
31
33
|
def primary_key(value)
|
32
|
-
associated_table.association_join_primary_key(
|
34
|
+
associated_table.association_join_primary_key(klass(value))
|
33
35
|
end
|
34
36
|
|
35
|
-
def
|
37
|
+
def klass(value)
|
36
38
|
case value
|
37
39
|
when Base
|
38
|
-
value.class
|
40
|
+
value.class
|
39
41
|
when Relation
|
40
|
-
value.klass
|
42
|
+
value.klass
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -16,15 +16,16 @@ module ActiveRecord
|
|
16
16
|
def call(attribute, value)
|
17
17
|
begin_bind = predicate_builder.build_bind_attribute(attribute.name, value.begin)
|
18
18
|
end_bind = predicate_builder.build_bind_attribute(attribute.name, value.end)
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
if begin_bind.value.infinity?
|
21
|
+
if end_bind.value.infinity?
|
21
22
|
attribute.not_in([])
|
22
23
|
elsif value.exclude_end?
|
23
24
|
attribute.lt(end_bind)
|
24
25
|
else
|
25
26
|
attribute.lteq(end_bind)
|
26
27
|
end
|
27
|
-
elsif
|
28
|
+
elsif end_bind.value.infinity?
|
28
29
|
attribute.gteq(begin_bind)
|
29
30
|
elsif value.exclude_end?
|
30
31
|
attribute.gteq(begin_bind).and(attribute.lt(end_bind))
|
@@ -21,6 +21,23 @@ module ActiveRecord
|
|
21
21
|
!value_before_type_cast.is_a?(StatementCache::Substitute) &&
|
22
22
|
(value_before_type_cast.nil? || value_for_database.nil?)
|
23
23
|
end
|
24
|
+
|
25
|
+
def boundable?
|
26
|
+
return @_boundable if defined?(@_boundable)
|
27
|
+
nil?
|
28
|
+
@_boundable = true
|
29
|
+
rescue ::RangeError
|
30
|
+
@_boundable = false
|
31
|
+
end
|
32
|
+
|
33
|
+
def infinity?
|
34
|
+
_infinity?(value_before_type_cast) || boundable? && _infinity?(value_for_database)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def _infinity?(value)
|
39
|
+
value.respond_to?(:infinite?) && value.infinite?
|
40
|
+
end
|
24
41
|
end
|
25
42
|
end
|
26
43
|
end
|
@@ -23,7 +23,7 @@ module ActiveRecord
|
|
23
23
|
relation = build_relation(finder_class, attribute, value)
|
24
24
|
if record.persisted?
|
25
25
|
if finder_class.primary_key
|
26
|
-
relation = relation.where.not(finder_class.primary_key => record.id_in_database
|
26
|
+
relation = relation.where.not(finder_class.primary_key => record.id_in_database)
|
27
27
|
else
|
28
28
|
raise UnknownPrimaryKey.new(finder_class, "Can not validate uniqueness for persisted record without primary key.")
|
29
29
|
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.2.0.
|
4
|
+
version: 5.2.0.rc2
|
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: 2018-
|
11
|
+
date: 2018-03-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.2.0.
|
19
|
+
version: 5.2.0.rc2
|
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.0.
|
26
|
+
version: 5.2.0.rc2
|
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.0.
|
33
|
+
version: 5.2.0.rc2
|
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.0.
|
40
|
+
version: 5.2.0.rc2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb
|
152
152
|
- lib/active_record/connection_adapters/postgresql/oid/bytea.rb
|
153
153
|
- lib/active_record/connection_adapters/postgresql/oid/cidr.rb
|
154
|
+
- lib/active_record/connection_adapters/postgresql/oid/date.rb
|
154
155
|
- lib/active_record/connection_adapters/postgresql/oid/date_time.rb
|
155
156
|
- lib/active_record/connection_adapters/postgresql/oid/decimal.rb
|
156
157
|
- lib/active_record/connection_adapters/postgresql/oid/enum.rb
|
@@ -306,8 +307,8 @@ homepage: http://rubyonrails.org
|
|
306
307
|
licenses:
|
307
308
|
- MIT
|
308
309
|
metadata:
|
309
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.
|
310
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.
|
310
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc2/activerecord
|
311
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc2/activerecord/CHANGELOG.md
|
311
312
|
post_install_message:
|
312
313
|
rdoc_options:
|
313
314
|
- "--main"
|
@@ -326,7 +327,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
327
|
version: 1.3.1
|
327
328
|
requirements: []
|
328
329
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.7.
|
330
|
+
rubygems_version: 2.7.6
|
330
331
|
signing_key:
|
331
332
|
specification_version: 4
|
332
333
|
summary: Object-relational mapper framework (part of Rails).
|