activerecord 6.0.0 → 6.0.3
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 +185 -1
- data/README.rdoc +1 -1
- data/lib/active_record.rb +1 -0
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +0 -1
- data/lib/active_record/association_relation.rb +10 -8
- data/lib/active_record/associations.rb +2 -2
- data/lib/active_record/associations/alias_tracker.rb +0 -1
- data/lib/active_record/associations/association.rb +5 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -2
- data/lib/active_record/associations/collection_association.rb +6 -2
- data/lib/active_record/associations/collection_proxy.rb +1 -2
- data/lib/active_record/associations/has_many_association.rb +0 -1
- data/lib/active_record/associations/join_dependency.rb +13 -0
- data/lib/active_record/associations/join_dependency/join_association.rb +1 -1
- data/lib/active_record/associations/preloader.rb +2 -3
- data/lib/active_record/attribute_assignment.rb +0 -1
- data/lib/active_record/attribute_decorators.rb +0 -2
- data/lib/active_record/attribute_methods/before_type_cast.rb +0 -1
- data/lib/active_record/attribute_methods/dirty.rb +2 -2
- data/lib/active_record/attribute_methods/primary_key.rb +0 -2
- data/lib/active_record/attribute_methods/read.rb +0 -1
- data/lib/active_record/attribute_methods/serialization.rb +0 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +0 -2
- data/lib/active_record/attribute_methods/write.rb +0 -1
- data/lib/active_record/attributes.rb +0 -1
- data/lib/active_record/autosave_association.rb +8 -6
- data/lib/active_record/callbacks.rb +1 -2
- data/lib/active_record/coders/yaml_column.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +14 -7
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +21 -15
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +27 -27
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +47 -30
- data/lib/active_record/connection_adapters/abstract/transaction.rb +4 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +23 -8
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +25 -32
- data/lib/active_record/connection_adapters/connection_specification.rb +2 -3
- data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +8 -12
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +8 -8
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +9 -3
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +15 -29
- data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +9 -2
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +8 -7
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +0 -1
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +3 -3
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +12 -7
- data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
- data/lib/active_record/connection_handling.rb +13 -22
- data/lib/active_record/core.rb +8 -6
- data/lib/active_record/counter_cache.rb +4 -1
- data/lib/active_record/database_configurations/url_config.rb +0 -1
- data/lib/active_record/dynamic_matchers.rb +2 -3
- data/lib/active_record/explain.rb +0 -1
- data/lib/active_record/fixture_set/table_row.rb +0 -1
- data/lib/active_record/fixture_set/table_rows.rb +0 -1
- data/lib/active_record/fixtures.rb +0 -3
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/inheritance.rb +0 -3
- data/lib/active_record/insert_all.rb +4 -4
- data/lib/active_record/internal_metadata.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +0 -1
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/middleware/database_selector.rb +0 -1
- data/lib/active_record/middleware/database_selector/resolver.rb +9 -14
- data/lib/active_record/migration.rb +4 -4
- data/lib/active_record/migration/command_recorder.rb +6 -18
- data/lib/active_record/migration/compatibility.rb +3 -3
- data/lib/active_record/migration/join_table.rb +0 -1
- data/lib/active_record/model_schema.rb +3 -2
- data/lib/active_record/nested_attributes.rb +0 -2
- data/lib/active_record/no_touching.rb +2 -2
- data/lib/active_record/null_relation.rb +0 -1
- data/lib/active_record/persistence.rb +4 -5
- data/lib/active_record/querying.rb +1 -1
- data/lib/active_record/railtie.rb +1 -1
- data/lib/active_record/railties/collection_cache_association_loading.rb +1 -1
- data/lib/active_record/railties/databases.rake +3 -0
- data/lib/active_record/reflection.rb +8 -8
- data/lib/active_record/relation.rb +13 -1
- data/lib/active_record/relation/batches.rb +0 -1
- data/lib/active_record/relation/calculations.rb +1 -1
- data/lib/active_record/relation/delegation.rb +7 -6
- data/lib/active_record/relation/finder_methods.rb +10 -2
- data/lib/active_record/relation/from_clause.rb +4 -0
- data/lib/active_record/relation/merger.rb +0 -1
- data/lib/active_record/relation/predicate_builder.rb +1 -5
- data/lib/active_record/relation/query_methods.rb +37 -12
- data/lib/active_record/relation/spawn_methods.rb +0 -1
- data/lib/active_record/relation/where_clause.rb +0 -1
- data/lib/active_record/result.rb +0 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/scoping.rb +0 -1
- data/lib/active_record/scoping/default.rb +0 -1
- data/lib/active_record/scoping/named.rb +3 -3
- data/lib/active_record/store.rb +1 -1
- data/lib/active_record/suppressor.rb +2 -2
- data/lib/active_record/table_metadata.rb +16 -1
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -1
- data/lib/active_record/tasks/postgresql_database_tasks.rb +0 -1
- data/lib/active_record/tasks/sqlite_database_tasks.rb +0 -1
- data/lib/active_record/test_fixtures.rb +2 -1
- data/lib/active_record/timestamp.rb +0 -1
- data/lib/active_record/touch_later.rb +1 -2
- data/lib/active_record/transactions.rb +9 -9
- data/lib/active_record/type.rb +0 -1
- data/lib/active_record/type/adapter_specific_registry.rb +2 -5
- data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
- data/lib/active_record/type/serialized.rb +0 -1
- data/lib/active_record/type/type_map.rb +0 -1
- data/lib/active_record/type/unsigned_integer.rb +0 -1
- data/lib/active_record/validations.rb +2 -3
- data/lib/active_record/validations/associated.rb +1 -2
- data/lib/arel.rb +17 -6
- data/lib/arel/predications.rb +5 -6
- data/lib/arel/visitors/depth_first.rb +0 -1
- data/lib/arel/visitors/dot.rb +0 -1
- data/lib/arel/visitors/mssql.rb +0 -1
- data/lib/arel/visitors/oracle.rb +1 -2
- data/lib/arel/visitors/oracle12.rb +0 -1
- data/lib/arel/visitors/postgresql.rb +0 -1
- data/lib/arel/visitors/sqlite.rb +0 -1
- data/lib/arel/visitors/to_sql.rb +0 -1
- data/lib/arel/visitors/visitor.rb +0 -1
- data/lib/arel/visitors/where_sql.rb +0 -1
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
- data/lib/rails/generators/active_record/migration.rb +0 -1
- data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +1 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +0 -1
- metadata +13 -9
data/lib/active_record/type.rb
CHANGED
@@ -11,14 +11,13 @@ module ActiveRecord
|
|
11
11
|
end
|
12
12
|
|
13
13
|
private
|
14
|
-
|
15
14
|
def registration_klass
|
16
15
|
Registration
|
17
16
|
end
|
18
17
|
|
19
|
-
def find_registration(symbol, *args)
|
18
|
+
def find_registration(symbol, *args, **kwargs)
|
20
19
|
registrations
|
21
|
-
.select { |registration| registration.matches?(symbol, *args) }
|
20
|
+
.select { |registration| registration.matches?(symbol, *args, **kwargs) }
|
22
21
|
.max
|
23
22
|
end
|
24
23
|
end
|
@@ -53,7 +52,6 @@ module ActiveRecord
|
|
53
52
|
end
|
54
53
|
|
55
54
|
protected
|
56
|
-
|
57
55
|
attr_reader :name, :block, :adapter, :override
|
58
56
|
|
59
57
|
def priority
|
@@ -72,7 +70,6 @@ module ActiveRecord
|
|
72
70
|
end
|
73
71
|
|
74
72
|
private
|
75
|
-
|
76
73
|
def matches_adapter?(adapter: nil, **)
|
77
74
|
(self.adapter.nil? || adapter == self.adapter)
|
78
75
|
end
|
@@ -43,13 +43,13 @@ module ActiveRecord
|
|
43
43
|
# The validation context can be changed by passing <tt>context: context</tt>.
|
44
44
|
# The regular {ActiveRecord::Base#save}[rdoc-ref:Persistence#save] method is replaced
|
45
45
|
# with this when the validations module is mixed in, which it is by default.
|
46
|
-
def save(options
|
46
|
+
def save(**options)
|
47
47
|
perform_validations(options) ? super : false
|
48
48
|
end
|
49
49
|
|
50
50
|
# Attempts to save the record just like {ActiveRecord::Base#save}[rdoc-ref:Base#save] but
|
51
51
|
# will raise an ActiveRecord::RecordInvalid exception instead of returning +false+ if the record is not valid.
|
52
|
-
def save!(options
|
52
|
+
def save!(**options)
|
53
53
|
perform_validations(options) ? super : raise_validation_error
|
54
54
|
end
|
55
55
|
|
@@ -72,7 +72,6 @@ module ActiveRecord
|
|
72
72
|
alias_method :validate, :valid?
|
73
73
|
|
74
74
|
private
|
75
|
-
|
76
75
|
def default_validation_context
|
77
76
|
new_record? ? :create : :update
|
78
77
|
end
|
@@ -5,12 +5,11 @@ module ActiveRecord
|
|
5
5
|
class AssociatedValidator < ActiveModel::EachValidator #:nodoc:
|
6
6
|
def validate_each(record, attribute, value)
|
7
7
|
if Array(value).reject { |r| valid_object?(r) }.any?
|
8
|
-
record.errors.add(attribute, :invalid, options.merge(value: value))
|
8
|
+
record.errors.add(attribute, :invalid, **options.merge(value: value))
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
13
|
-
|
14
13
|
def valid_object?(record)
|
15
14
|
(record.respond_to?(:marked_for_destruction?) && record.marked_for_destruction?) || record.valid?
|
16
15
|
end
|
data/lib/arel.rb
CHANGED
@@ -24,28 +24,39 @@ require "arel/update_manager"
|
|
24
24
|
require "arel/delete_manager"
|
25
25
|
require "arel/nodes"
|
26
26
|
|
27
|
-
module Arel
|
27
|
+
module Arel
|
28
28
|
VERSION = "10.0.0"
|
29
29
|
|
30
|
+
# Wrap a known-safe SQL string for passing to query methods, e.g.
|
31
|
+
#
|
32
|
+
# Post.order(Arel.sql("length(title)")).last
|
33
|
+
#
|
34
|
+
# Great caution should be taken to avoid SQL injection vulnerabilities.
|
35
|
+
# This method should not be used with unsafe values such as request
|
36
|
+
# parameters or model attributes.
|
30
37
|
def self.sql(raw_sql)
|
31
38
|
Arel::Nodes::SqlLiteral.new raw_sql
|
32
39
|
end
|
33
40
|
|
34
|
-
def self.star
|
41
|
+
def self.star # :nodoc:
|
35
42
|
sql "*"
|
36
43
|
end
|
37
44
|
|
38
|
-
def self.arel_node?(value)
|
45
|
+
def self.arel_node?(value) # :nodoc:
|
39
46
|
value.is_a?(Arel::Node) || value.is_a?(Arel::Attribute) || value.is_a?(Arel::Nodes::SqlLiteral)
|
40
47
|
end
|
41
48
|
|
42
|
-
def self.fetch_attribute(value)
|
49
|
+
def self.fetch_attribute(value) # :nodoc:
|
43
50
|
case value
|
44
51
|
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
|
45
|
-
|
52
|
+
if value.left.is_a?(Arel::Attributes::Attribute)
|
53
|
+
yield value.left
|
54
|
+
elsif value.right.is_a?(Arel::Attributes::Attribute)
|
55
|
+
yield value.right
|
56
|
+
end
|
46
57
|
end
|
47
58
|
end
|
48
59
|
|
49
60
|
## Convenience Alias
|
50
|
-
Node = Arel::Nodes::Node
|
61
|
+
Node = Arel::Nodes::Node # :nodoc:
|
51
62
|
end
|
data/lib/arel/predications.rb
CHANGED
@@ -38,14 +38,14 @@ module Arel # :nodoc: all
|
|
38
38
|
if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1
|
39
39
|
self.in([])
|
40
40
|
elsif open_ended?(other.begin)
|
41
|
-
if
|
41
|
+
if open_ended?(other.end)
|
42
42
|
not_in([])
|
43
43
|
elsif other.exclude_end?
|
44
44
|
lt(other.end)
|
45
45
|
else
|
46
46
|
lteq(other.end)
|
47
47
|
end
|
48
|
-
elsif
|
48
|
+
elsif open_ended?(other.end)
|
49
49
|
gteq(other.begin)
|
50
50
|
elsif other.exclude_end?
|
51
51
|
gteq(other.begin).and(lt(other.end))
|
@@ -86,14 +86,14 @@ Passing a range to `#in` is deprecated. Call `#between`, instead.
|
|
86
86
|
if unboundable?(other.begin) == 1 || unboundable?(other.end) == -1
|
87
87
|
not_in([])
|
88
88
|
elsif open_ended?(other.begin)
|
89
|
-
if
|
89
|
+
if open_ended?(other.end)
|
90
90
|
self.in([])
|
91
91
|
elsif other.exclude_end?
|
92
92
|
gteq(other.end)
|
93
93
|
else
|
94
94
|
gt(other.end)
|
95
95
|
end
|
96
|
-
elsif
|
96
|
+
elsif open_ended?(other.end)
|
97
97
|
lt(other.begin)
|
98
98
|
else
|
99
99
|
left = lt(other.begin)
|
@@ -221,7 +221,6 @@ Passing a range to `#not_in` is deprecated. Call `#not_between`, instead.
|
|
221
221
|
end
|
222
222
|
|
223
223
|
private
|
224
|
-
|
225
224
|
def grouping_any(method_id, others, *extras)
|
226
225
|
nodes = others.map { |expr| send(method_id, expr, *extras) }
|
227
226
|
Nodes::Grouping.new nodes.inject { |memo, node|
|
@@ -251,7 +250,7 @@ Passing a range to `#not_in` is deprecated. Call `#not_between`, instead.
|
|
251
250
|
end
|
252
251
|
|
253
252
|
def open_ended?(value)
|
254
|
-
infinity?(value) || unboundable?(value)
|
253
|
+
value.nil? || infinity?(value) || unboundable?(value)
|
255
254
|
end
|
256
255
|
end
|
257
256
|
end
|
data/lib/arel/visitors/dot.rb
CHANGED
data/lib/arel/visitors/mssql.rb
CHANGED
data/lib/arel/visitors/oracle.rb
CHANGED
@@ -4,7 +4,6 @@ module Arel # :nodoc: all
|
|
4
4
|
module Visitors
|
5
5
|
class Oracle < Arel::Visitors::ToSql
|
6
6
|
private
|
7
|
-
|
8
7
|
def visit_Arel_Nodes_SelectStatement(o, collector)
|
9
8
|
o = order_hacks(o)
|
10
9
|
|
@@ -123,7 +122,7 @@ module Arel # :nodoc: all
|
|
123
122
|
o.orders = []
|
124
123
|
orders.each_with_index do |order, i|
|
125
124
|
o.orders <<
|
126
|
-
Nodes::SqlLiteral.new("alias_#{i}__#{' DESC' if /\bdesc$/i
|
125
|
+
Nodes::SqlLiteral.new("alias_#{i}__#{' DESC' if /\bdesc$/i.match?(order)}")
|
127
126
|
end
|
128
127
|
o
|
129
128
|
end
|
data/lib/arel/visitors/sqlite.rb
CHANGED
data/lib/arel/visitors/to_sql.rb
CHANGED
@@ -37,7 +37,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Mi
|
|
37
37
|
<%- if attribute.has_index? -%>
|
38
38
|
remove_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
|
39
39
|
<%- end -%>
|
40
|
-
<%- if !attribute.virtual?
|
40
|
+
<%- if !attribute.virtual? -%>
|
41
41
|
remove_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
|
42
42
|
<%- end -%>
|
43
43
|
<%- 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: 6.0.
|
4
|
+
version: 6.0.3
|
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:
|
11
|
+
date: 2020-05-06 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: 6.0.
|
19
|
+
version: 6.0.3
|
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: 6.0.
|
26
|
+
version: 6.0.3
|
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: 6.0.
|
33
|
+
version: 6.0.3
|
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: 6.0.
|
40
|
+
version: 6.0.3
|
41
41
|
description: Databases on Rails. Build a persistent domain model by mapping database
|
42
42
|
tables to Ruby classes. Strong conventions for associations, validations, aggregations,
|
43
43
|
migrations, and testing come baked-in.
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- examples/performance.rb
|
54
54
|
- examples/simple.rb
|
55
55
|
- lib/active_record.rb
|
56
|
+
- lib/active_record/advisory_lock_base.rb
|
56
57
|
- lib/active_record/aggregations.rb
|
57
58
|
- lib/active_record/association_relation.rb
|
58
59
|
- lib/active_record/associations.rb
|
@@ -389,8 +390,11 @@ homepage: https://rubyonrails.org
|
|
389
390
|
licenses:
|
390
391
|
- MIT
|
391
392
|
metadata:
|
392
|
-
|
393
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
393
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
394
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.3/activerecord/CHANGELOG.md
|
395
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.3/
|
396
|
+
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
397
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.3/activerecord
|
394
398
|
post_install_message:
|
395
399
|
rdoc_options:
|
396
400
|
- "--main"
|
@@ -408,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
408
412
|
- !ruby/object:Gem::Version
|
409
413
|
version: '0'
|
410
414
|
requirements: []
|
411
|
-
rubygems_version: 3.
|
415
|
+
rubygems_version: 3.1.2
|
412
416
|
signing_key:
|
413
417
|
specification_version: 4
|
414
418
|
summary: Object-relational mapper framework (part of Rails).
|