activerecord 5.2.0.beta2 → 5.2.0.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 +5 -5
- data/CHANGELOG.md +231 -2
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_record.rb +1 -1
- data/lib/active_record/aggregations.rb +4 -5
- data/lib/active_record/association_relation.rb +2 -2
- data/lib/active_record/associations.rb +18 -12
- data/lib/active_record/associations/alias_tracker.rb +2 -10
- data/lib/active_record/associations/association.rb +1 -1
- data/lib/active_record/associations/belongs_to_association.rb +9 -9
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +1 -6
- data/lib/active_record/associations/builder/association.rb +2 -2
- data/lib/active_record/associations/builder/belongs_to.rb +7 -3
- data/lib/active_record/associations/collection_association.rb +2 -2
- data/lib/active_record/associations/collection_proxy.rb +1 -1
- data/lib/active_record/associations/has_many_association.rb +1 -1
- data/lib/active_record/associations/has_many_through_association.rb +4 -17
- data/lib/active_record/associations/has_one_through_association.rb +5 -6
- data/lib/active_record/associations/preloader.rb +1 -1
- data/lib/active_record/associations/preloader/association.rb +2 -2
- data/lib/active_record/associations/through_association.rb +22 -9
- data/lib/active_record/attribute_methods.rb +1 -5
- data/lib/active_record/attribute_methods/dirty.rb +2 -4
- data/lib/active_record/attributes.rb +1 -1
- data/lib/active_record/autosave_association.rb +3 -0
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/collection_cache_key.rb +5 -6
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +1 -3
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +57 -21
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +20 -3
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +55 -15
- data/lib/active_record/connection_adapters/abstract_adapter.rb +19 -6
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +55 -64
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +8 -1
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +0 -4
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +21 -6
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +9 -1
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +12 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +13 -4
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +170 -48
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +15 -5
- data/lib/active_record/connection_adapters/schema_cache.rb +2 -2
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +63 -18
- data/lib/active_record/core.rb +12 -3
- data/lib/active_record/enum.rb +2 -0
- data/lib/active_record/fixtures.rb +28 -37
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/inheritance.rb +3 -4
- data/lib/active_record/log_subscriber.rb +41 -0
- data/lib/active_record/migration.rb +138 -120
- data/lib/active_record/migration/compatibility.rb +20 -0
- data/lib/active_record/model_schema.rb +19 -16
- data/lib/active_record/persistence.rb +8 -11
- data/lib/active_record/railtie.rb +7 -2
- data/lib/active_record/railties/databases.rake +8 -11
- data/lib/active_record/reflection.rb +10 -13
- data/lib/active_record/relation.rb +27 -17
- data/lib/active_record/relation/calculations.rb +17 -12
- data/lib/active_record/relation/finder_methods.rb +30 -37
- data/lib/active_record/relation/merger.rb +30 -2
- data/lib/active_record/relation/predicate_builder.rb +12 -0
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +1 -1
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -1
- data/lib/active_record/relation/query_methods.rb +14 -24
- data/lib/active_record/relation/spawn_methods.rb +1 -1
- data/lib/active_record/relation/where_clause.rb +16 -2
- data/lib/active_record/relation/where_clause_factory.rb +1 -2
- data/lib/active_record/sanitization.rb +130 -128
- data/lib/active_record/schema.rb +1 -1
- data/lib/active_record/schema_dumper.rb +12 -3
- data/lib/active_record/scoping/named.rb +6 -0
- data/lib/active_record/store.rb +1 -1
- data/lib/active_record/table_metadata.rb +10 -3
- data/lib/active_record/tasks/database_tasks.rb +4 -4
- data/lib/active_record/type_caster/map.rb +1 -1
- metadata +9 -9
data/lib/active_record/schema.rb
CHANGED
@@ -55,7 +55,7 @@ module ActiveRecord
|
|
55
55
|
end
|
56
56
|
|
57
57
|
ActiveRecord::InternalMetadata.create_table
|
58
|
-
ActiveRecord::InternalMetadata[:environment] =
|
58
|
+
ActiveRecord::InternalMetadata[:environment] = connection.migration_context.current_environment
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
@@ -44,7 +44,7 @@ module ActiveRecord
|
|
44
44
|
|
45
45
|
def initialize(connection, options = {})
|
46
46
|
@connection = connection
|
47
|
-
@version =
|
47
|
+
@version = connection.migration_context.current_version rescue nil
|
48
48
|
@options = options
|
49
49
|
end
|
50
50
|
|
@@ -184,8 +184,9 @@ HEADER
|
|
184
184
|
"name: #{index.name.inspect}",
|
185
185
|
]
|
186
186
|
index_parts << "unique: true" if index.unique
|
187
|
-
index_parts << "length:
|
188
|
-
index_parts << "order:
|
187
|
+
index_parts << "length: #{format_index_parts(index.lengths)}" if index.lengths.present?
|
188
|
+
index_parts << "order: #{format_index_parts(index.orders)}" if index.orders.present?
|
189
|
+
index_parts << "opclass: #{format_index_parts(index.opclasses)}" if index.opclasses.present?
|
189
190
|
index_parts << "where: #{index.where.inspect}" if index.where
|
190
191
|
index_parts << "using: #{index.using.inspect}" if !@connection.default_index_type?(index)
|
191
192
|
index_parts << "type: #{index.type.inspect}" if index.type
|
@@ -231,6 +232,14 @@ HEADER
|
|
231
232
|
options.map { |key, value| "#{key}: #{value.inspect}" }.join(", ")
|
232
233
|
end
|
233
234
|
|
235
|
+
def format_index_parts(options)
|
236
|
+
if options.is_a?(Hash)
|
237
|
+
"{ #{format_options(options)} }"
|
238
|
+
else
|
239
|
+
options.inspect
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
234
243
|
def remove_prefix_and_suffix(table)
|
235
244
|
prefix = Regexp.escape(@options[:table_name_prefix].to_s)
|
236
245
|
suffix = Regexp.escape(@options[:table_name_suffix].to_s)
|
@@ -171,6 +171,12 @@ module ActiveRecord
|
|
171
171
|
"a class method with the same name."
|
172
172
|
end
|
173
173
|
|
174
|
+
if method_defined_within?(name, Relation)
|
175
|
+
raise ArgumentError, "You tried to define a scope named \"#{name}\" " \
|
176
|
+
"on the model \"#{self.name}\", but ActiveRecord::Relation already defined " \
|
177
|
+
"an instance method with the same name."
|
178
|
+
end
|
179
|
+
|
174
180
|
valid_scope_name?(name)
|
175
181
|
extension = Module.new(&block) if block
|
176
182
|
|
data/lib/active_record/store.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
4
|
class TableMetadata # :nodoc:
|
5
|
-
delegate :foreign_type, :foreign_key, :
|
6
|
-
delegate :association_primary_key, to: :association
|
5
|
+
delegate :foreign_type, :foreign_key, :join_primary_key, :join_foreign_key, to: :association, prefix: true
|
7
6
|
|
8
7
|
def initialize(klass, arel_table, association = nil)
|
9
8
|
@klass = klass
|
@@ -31,7 +30,7 @@ module ActiveRecord
|
|
31
30
|
|
32
31
|
def type(column_name)
|
33
32
|
if klass
|
34
|
-
klass.type_for_attribute(column_name
|
33
|
+
klass.type_for_attribute(column_name)
|
35
34
|
else
|
36
35
|
Type.default_value
|
37
36
|
end
|
@@ -66,6 +65,14 @@ module ActiveRecord
|
|
66
65
|
association && association.polymorphic?
|
67
66
|
end
|
68
67
|
|
68
|
+
def aggregated_with?(aggregation_name)
|
69
|
+
klass && reflect_on_aggregation(aggregation_name)
|
70
|
+
end
|
71
|
+
|
72
|
+
def reflect_on_aggregation(aggregation_name)
|
73
|
+
klass.reflect_on_aggregation(aggregation_name)
|
74
|
+
end
|
75
|
+
|
69
76
|
# TODO Change this to private once we've dropped Ruby 2.2 support.
|
70
77
|
# Workaround for Ruby 2.2 "private attribute?" warning.
|
71
78
|
protected
|
@@ -54,10 +54,10 @@ module ActiveRecord
|
|
54
54
|
|
55
55
|
def check_protected_environments!
|
56
56
|
unless ENV["DISABLE_DATABASE_ENVIRONMENT_CHECK"]
|
57
|
-
current = ActiveRecord::
|
58
|
-
stored = ActiveRecord::
|
57
|
+
current = ActiveRecord::Base.connection.migration_context.current_environment
|
58
|
+
stored = ActiveRecord::Base.connection.migration_context.last_stored_environment
|
59
59
|
|
60
|
-
if ActiveRecord::
|
60
|
+
if ActiveRecord::Base.connection.migration_context.protected_environment?
|
61
61
|
raise ActiveRecord::ProtectedEnvironmentError.new(stored)
|
62
62
|
end
|
63
63
|
|
@@ -169,7 +169,7 @@ module ActiveRecord
|
|
169
169
|
verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] != "false" : true
|
170
170
|
scope = ENV["SCOPE"]
|
171
171
|
verbose_was, Migration.verbose = Migration.verbose, verbose
|
172
|
-
|
172
|
+
Base.connection.migration_context.migrate(target_version) do |migration|
|
173
173
|
scope.blank? || scope == migration.scope
|
174
174
|
end
|
175
175
|
ActiveRecord::Base.clear_cache!
|
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.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:
|
11
|
+
date: 2018-01-30 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.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.0.
|
26
|
+
version: 5.2.0.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.0.
|
33
|
+
version: 5.2.0.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.0.
|
40
|
+
version: 5.2.0.rc1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,8 +306,8 @@ homepage: http://rubyonrails.org
|
|
306
306
|
licenses:
|
307
307
|
- MIT
|
308
308
|
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.
|
309
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.rc1/activerecord
|
310
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.rc1/activerecord/CHANGELOG.md
|
311
311
|
post_install_message:
|
312
312
|
rdoc_options:
|
313
313
|
- "--main"
|
@@ -326,7 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
version: 1.3.1
|
327
327
|
requirements: []
|
328
328
|
rubyforge_project:
|
329
|
-
rubygems_version: 2.
|
329
|
+
rubygems_version: 2.7.3
|
330
330
|
signing_key:
|
331
331
|
specification_version: 4
|
332
332
|
summary: Object-relational mapper framework (part of Rails).
|