activerecord 5.1.7 → 5.2.0.beta1
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 +221 -900
- data/README.rdoc +3 -3
- data/examples/performance.rb +2 -0
- data/examples/simple.rb +2 -0
- data/lib/active_record.rb +10 -3
- data/lib/active_record/aggregations.rb +2 -0
- data/lib/active_record/association_relation.rb +2 -0
- data/lib/active_record/associations.rb +13 -42
- data/lib/active_record/associations/alias_tracker.rb +17 -17
- data/lib/active_record/associations/association.rb +11 -22
- data/lib/active_record/associations/association_scope.rb +32 -44
- data/lib/active_record/associations/belongs_to_association.rb +6 -4
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +3 -1
- data/lib/active_record/associations/builder/association.rb +2 -5
- data/lib/active_record/associations/builder/belongs_to.rb +7 -12
- data/lib/active_record/associations/builder/collection_association.rb +1 -1
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +3 -1
- data/lib/active_record/associations/builder/has_many.rb +2 -0
- data/lib/active_record/associations/builder/has_one.rb +2 -0
- data/lib/active_record/associations/builder/singular_association.rb +2 -0
- data/lib/active_record/associations/collection_association.rb +41 -33
- data/lib/active_record/associations/collection_proxy.rb +11 -14
- data/lib/active_record/associations/foreign_association.rb +2 -0
- data/lib/active_record/associations/has_many_association.rb +4 -2
- data/lib/active_record/associations/has_many_through_association.rb +4 -2
- data/lib/active_record/associations/has_one_association.rb +3 -1
- data/lib/active_record/associations/has_one_through_association.rb +3 -1
- data/lib/active_record/associations/join_dependency.rb +22 -40
- data/lib/active_record/associations/join_dependency/join_association.rb +17 -56
- data/lib/active_record/associations/join_dependency/join_base.rb +9 -8
- data/lib/active_record/associations/join_dependency/join_part.rb +2 -9
- data/lib/active_record/associations/preloader.rb +17 -37
- data/lib/active_record/associations/preloader/association.rb +42 -58
- data/lib/active_record/associations/preloader/through_association.rb +71 -79
- data/lib/active_record/associations/singular_association.rb +14 -10
- data/lib/active_record/associations/through_association.rb +3 -1
- data/lib/active_record/attribute_assignment.rb +2 -0
- data/lib/active_record/attribute_decorators.rb +3 -2
- data/lib/active_record/attribute_methods.rb +47 -7
- data/lib/active_record/attribute_methods/before_type_cast.rb +2 -0
- data/lib/active_record/attribute_methods/dirty.rb +25 -214
- data/lib/active_record/attribute_methods/primary_key.rb +7 -6
- data/lib/active_record/attribute_methods/query.rb +2 -0
- data/lib/active_record/attribute_methods/read.rb +8 -2
- data/lib/active_record/attribute_methods/serialization.rb +23 -0
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +6 -8
- data/lib/active_record/attribute_methods/write.rb +21 -9
- data/lib/active_record/attributes.rb +7 -6
- data/lib/active_record/autosave_association.rb +5 -11
- data/lib/active_record/base.rb +2 -0
- data/lib/active_record/callbacks.rb +6 -8
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +2 -0
- data/lib/active_record/collection_cache_key.rb +10 -5
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +110 -35
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +120 -28
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +7 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +14 -33
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +13 -5
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +40 -2
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +31 -53
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +103 -63
- data/lib/active_record/connection_adapters/abstract/transaction.rb +45 -9
- data/lib/active_record/connection_adapters/abstract_adapter.rb +62 -90
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +75 -138
- data/lib/active_record/connection_adapters/column.rb +3 -1
- data/lib/active_record/connection_adapters/connection_specification.rb +17 -3
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +3 -1
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +9 -10
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +5 -3
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +7 -6
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +30 -30
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +91 -1
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +8 -2
- data/lib/active_record/connection_adapters/postgresql/column.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -0
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +2 -1
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +3 -11
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +3 -5
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +10 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +19 -25
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +11 -7
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +20 -13
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +79 -65
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +47 -82
- data/lib/active_record/connection_adapters/schema_cache.rb +2 -0
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +19 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +2 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +6 -15
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +3 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +71 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -89
- data/lib/active_record/connection_adapters/statement_pool.rb +2 -0
- data/lib/active_record/connection_handling.rb +4 -2
- data/lib/active_record/core.rb +27 -57
- data/lib/active_record/counter_cache.rb +15 -12
- data/lib/active_record/define_callbacks.rb +5 -3
- data/lib/active_record/dynamic_matchers.rb +9 -9
- data/lib/active_record/enum.rb +15 -13
- data/lib/active_record/errors.rb +54 -21
- data/lib/active_record/explain.rb +3 -1
- data/lib/active_record/explain_registry.rb +2 -0
- data/lib/active_record/explain_subscriber.rb +2 -0
- data/lib/active_record/fixture_set/file.rb +2 -0
- data/lib/active_record/fixtures.rb +40 -24
- data/lib/active_record/gem_version.rb +5 -3
- data/lib/active_record/inheritance.rb +6 -5
- data/lib/active_record/integration.rb +58 -19
- data/lib/active_record/internal_metadata.rb +2 -0
- data/lib/active_record/legacy_yaml_adapter.rb +3 -1
- data/lib/active_record/locking/optimistic.rb +31 -20
- data/lib/active_record/locking/pessimistic.rb +10 -7
- data/lib/active_record/log_subscriber.rb +2 -0
- data/lib/active_record/migration.rb +47 -21
- data/lib/active_record/migration/command_recorder.rb +11 -9
- data/lib/active_record/migration/compatibility.rb +20 -2
- data/lib/active_record/migration/join_table.rb +2 -0
- data/lib/active_record/model_schema.rb +29 -38
- data/lib/active_record/nested_attributes.rb +18 -6
- data/lib/active_record/no_touching.rb +3 -1
- data/lib/active_record/null_relation.rb +2 -0
- data/lib/active_record/persistence.rb +184 -40
- data/lib/active_record/query_cache.rb +17 -12
- data/lib/active_record/querying.rb +3 -1
- data/lib/active_record/railtie.rb +54 -1
- data/lib/active_record/railties/console_sandbox.rb +2 -0
- data/lib/active_record/railties/controller_runtime.rb +2 -0
- data/lib/active_record/railties/databases.rake +41 -28
- data/lib/active_record/readonly_attributes.rb +3 -2
- data/lib/active_record/reflection.rb +100 -182
- data/lib/active_record/relation.rb +61 -193
- data/lib/active_record/relation/batches.rb +20 -5
- data/lib/active_record/relation/batches/batch_enumerator.rb +2 -0
- data/lib/active_record/relation/calculations.rb +40 -23
- data/lib/active_record/relation/delegation.rb +10 -27
- data/lib/active_record/relation/finder_methods.rb +53 -49
- data/lib/active_record/relation/from_clause.rb +2 -8
- data/lib/active_record/relation/merger.rb +22 -19
- data/lib/active_record/relation/predicate_builder.rb +42 -79
- data/lib/active_record/relation/predicate_builder/array_handler.rb +10 -7
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +46 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +2 -2
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +12 -1
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +54 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +22 -6
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/query_attribute.rb +9 -2
- data/lib/active_record/relation/query_methods.rb +80 -69
- data/lib/active_record/relation/record_fetch_warning.rb +2 -0
- data/lib/active_record/relation/spawn_methods.rb +2 -0
- data/lib/active_record/relation/where_clause.rb +50 -67
- data/lib/active_record/relation/where_clause_factory.rb +4 -46
- data/lib/active_record/result.rb +2 -0
- data/lib/active_record/runtime_registry.rb +2 -0
- data/lib/active_record/sanitization.rb +15 -9
- data/lib/active_record/schema.rb +3 -1
- data/lib/active_record/schema_dumper.rb +24 -23
- data/lib/active_record/schema_migration.rb +2 -0
- data/lib/active_record/scoping.rb +9 -8
- data/lib/active_record/scoping/default.rb +6 -7
- data/lib/active_record/scoping/named.rb +15 -7
- data/lib/active_record/secure_token.rb +2 -0
- data/lib/active_record/serialization.rb +2 -0
- data/lib/active_record/statement_cache.rb +22 -12
- data/lib/active_record/store.rb +2 -0
- data/lib/active_record/suppressor.rb +2 -0
- data/lib/active_record/table_metadata.rb +3 -1
- data/lib/active_record/tasks/database_tasks.rb +23 -12
- data/lib/active_record/tasks/mysql_database_tasks.rb +9 -48
- data/lib/active_record/tasks/postgresql_database_tasks.rb +10 -2
- data/lib/active_record/tasks/sqlite_database_tasks.rb +25 -3
- data/lib/active_record/timestamp.rb +5 -12
- data/lib/active_record/touch_later.rb +2 -0
- data/lib/active_record/transactions.rb +9 -7
- data/lib/active_record/translation.rb +2 -0
- data/lib/active_record/type.rb +4 -1
- data/lib/active_record/type/adapter_specific_registry.rb +2 -0
- data/lib/active_record/type/date.rb +2 -0
- data/lib/active_record/type/date_time.rb +2 -0
- data/lib/active_record/type/decimal_without_scale.rb +2 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +2 -0
- data/lib/active_record/type/internal/timezone.rb +2 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +2 -4
- data/lib/active_record/type/text.rb +2 -0
- data/lib/active_record/type/time.rb +2 -0
- data/lib/active_record/type/type_map.rb +2 -0
- data/lib/active_record/type/unsigned_integer.rb +2 -0
- data/lib/active_record/type_caster.rb +2 -0
- data/lib/active_record/type_caster/connection.rb +2 -0
- data/lib/active_record/type_caster/map.rb +2 -0
- data/lib/active_record/validations.rb +2 -0
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +2 -0
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +2 -0
- data/lib/active_record/validations/uniqueness.rb +36 -6
- data/lib/active_record/version.rb +2 -0
- data/lib/rails/generators/active_record.rb +3 -1
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/{model/templates/application_record.rb → application_record/templates/application_record.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration.rb +2 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +3 -1
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +0 -0
- data/lib/rails/generators/active_record/model/model_generator.rb +2 -23
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +0 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- metadata +25 -38
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -15
- data/lib/active_record/associations/preloader/collection_association.rb +0 -17
- data/lib/active_record/associations/preloader/has_many.rb +0 -15
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
- data/lib/active_record/associations/preloader/has_one.rb +0 -15
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -18
- data/lib/active_record/attribute.rb +0 -240
- data/lib/active_record/attribute/user_provided_default.rb +0 -30
- data/lib/active_record/attribute_mutation_tracker.rb +0 -122
- data/lib/active_record/attribute_set.rb +0 -113
- data/lib/active_record/attribute_set/builder.rb +0 -126
- data/lib/active_record/attribute_set/yaml_encoder.rb +0 -41
- data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -10
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/relation/predicate_builder/association_query_handler.rb +0 -88
- data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -59
- data/lib/active_record/type/internal/abstract_json.rb +0 -37
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/named_base"
|
2
4
|
require "rails/generators/active_model"
|
3
5
|
require "rails/generators/active_record/migration"
|
@@ -10,7 +12,7 @@ module ActiveRecord
|
|
10
12
|
|
11
13
|
# Set the current directory as base for the inherited generators.
|
12
14
|
def self.base_root
|
13
|
-
|
15
|
+
__dir__
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/active_record"
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
module Generators # :nodoc:
|
7
|
+
class ApplicationRecordGenerator < ::Rails::Generators::Base # :nodoc:
|
8
|
+
source_root File.expand_path("templates", __dir__)
|
9
|
+
|
10
|
+
# FIXME: Change this file to a symlink once RubyGems 2.5.0 is required.
|
11
|
+
def create_application_record
|
12
|
+
template "application_record.rb", application_record_file_name
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def application_record_file_name
|
18
|
+
@application_record_file_name ||=
|
19
|
+
if namespaced?
|
20
|
+
"app/models/#{namespaced_path}/application_record.rb"
|
21
|
+
else
|
22
|
+
"app/models/application_record.rb"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/active_record"
|
2
4
|
|
3
5
|
module ActiveRecord
|
@@ -26,7 +28,7 @@ module ActiveRecord
|
|
26
28
|
def set_local_assigns!
|
27
29
|
@migration_template = "migration.rb"
|
28
30
|
case file_name
|
29
|
-
when /^(add
|
31
|
+
when /^(add)_.*_to_(.*)/, /^(remove)_.*?_from_(.*)/
|
30
32
|
@migration_action = $1
|
31
33
|
@table_name = normalize_table_name($2)
|
32
34
|
when /join_table/
|
File without changes
|
data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt}
RENAMED
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rails/generators/active_record"
|
2
4
|
|
3
5
|
module ActiveRecord
|
@@ -21,13 +23,11 @@ module ActiveRecord
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def create_model_file
|
24
|
-
generate_application_record
|
25
26
|
template "model.rb", File.join("app/models", class_path, "#{file_name}.rb")
|
26
27
|
end
|
27
28
|
|
28
29
|
def create_module_file
|
29
30
|
return if regular_class_path.empty?
|
30
|
-
generate_application_record
|
31
31
|
template "module.rb", File.join("app/models", "#{class_path.join('/')}.rb") if behavior == :invoke
|
32
32
|
end
|
33
33
|
|
@@ -39,31 +39,10 @@ module ActiveRecord
|
|
39
39
|
attributes.select { |a| !a.reference? && a.has_index? }
|
40
40
|
end
|
41
41
|
|
42
|
-
# FIXME: Change this file to a symlink once RubyGems 2.5.0 is required.
|
43
|
-
def generate_application_record
|
44
|
-
if behavior == :invoke && !application_record_exist?
|
45
|
-
template "application_record.rb", application_record_file_name
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
42
|
# Used by the migration template to determine the parent name of the model
|
50
43
|
def parent_class_name
|
51
44
|
options[:parent] || "ApplicationRecord"
|
52
45
|
end
|
53
|
-
|
54
|
-
def application_record_exist?
|
55
|
-
file_exist = nil
|
56
|
-
in_root { file_exist = File.exist?(application_record_file_name) }
|
57
|
-
file_exist
|
58
|
-
end
|
59
|
-
|
60
|
-
def application_record_file_name
|
61
|
-
@application_record_file_name ||= if mountable_engine?
|
62
|
-
"app/models/#{namespaced_path}/application_record.rb"
|
63
|
-
else
|
64
|
-
"app/models/application_record.rb"
|
65
|
-
end
|
66
|
-
end
|
67
46
|
end
|
68
47
|
end
|
69
48
|
end
|
File without changes
|
File without changes
|
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.
|
4
|
+
version: 5.2.0.beta1
|
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: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.2.0.beta1
|
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.
|
26
|
+
version: 5.2.0.beta1
|
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.
|
33
|
+
version: 5.2.0.beta1
|
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.
|
40
|
+
version: 5.2.0.beta1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '9.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '9.0'
|
55
55
|
description: Databases on Rails. Build a persistent domain model by mapping database
|
56
56
|
tables to Ruby classes. Strong conventions for associations, validations, aggregations,
|
57
57
|
migrations, and testing come baked-in.
|
@@ -95,18 +95,9 @@ files:
|
|
95
95
|
- lib/active_record/associations/join_dependency/join_part.rb
|
96
96
|
- lib/active_record/associations/preloader.rb
|
97
97
|
- lib/active_record/associations/preloader/association.rb
|
98
|
-
- lib/active_record/associations/preloader/belongs_to.rb
|
99
|
-
- lib/active_record/associations/preloader/collection_association.rb
|
100
|
-
- lib/active_record/associations/preloader/has_many.rb
|
101
|
-
- lib/active_record/associations/preloader/has_many_through.rb
|
102
|
-
- lib/active_record/associations/preloader/has_one.rb
|
103
|
-
- lib/active_record/associations/preloader/has_one_through.rb
|
104
|
-
- lib/active_record/associations/preloader/singular_association.rb
|
105
98
|
- lib/active_record/associations/preloader/through_association.rb
|
106
99
|
- lib/active_record/associations/singular_association.rb
|
107
100
|
- lib/active_record/associations/through_association.rb
|
108
|
-
- lib/active_record/attribute.rb
|
109
|
-
- lib/active_record/attribute/user_provided_default.rb
|
110
101
|
- lib/active_record/attribute_assignment.rb
|
111
102
|
- lib/active_record/attribute_decorators.rb
|
112
103
|
- lib/active_record/attribute_methods.rb
|
@@ -118,10 +109,6 @@ files:
|
|
118
109
|
- lib/active_record/attribute_methods/serialization.rb
|
119
110
|
- lib/active_record/attribute_methods/time_zone_conversion.rb
|
120
111
|
- lib/active_record/attribute_methods/write.rb
|
121
|
-
- lib/active_record/attribute_mutation_tracker.rb
|
122
|
-
- lib/active_record/attribute_set.rb
|
123
|
-
- lib/active_record/attribute_set/builder.rb
|
124
|
-
- lib/active_record/attribute_set/yaml_encoder.rb
|
125
112
|
- lib/active_record/attributes.rb
|
126
113
|
- lib/active_record/autosave_association.rb
|
127
114
|
- lib/active_record/base.rb
|
@@ -169,7 +156,6 @@ files:
|
|
169
156
|
- lib/active_record/connection_adapters/postgresql/oid/enum.rb
|
170
157
|
- lib/active_record/connection_adapters/postgresql/oid/hstore.rb
|
171
158
|
- lib/active_record/connection_adapters/postgresql/oid/inet.rb
|
172
|
-
- lib/active_record/connection_adapters/postgresql/oid/json.rb
|
173
159
|
- lib/active_record/connection_adapters/postgresql/oid/jsonb.rb
|
174
160
|
- lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb
|
175
161
|
- lib/active_record/connection_adapters/postgresql/oid/money.rb
|
@@ -236,7 +222,6 @@ files:
|
|
236
222
|
- lib/active_record/railties/console_sandbox.rb
|
237
223
|
- lib/active_record/railties/controller_runtime.rb
|
238
224
|
- lib/active_record/railties/databases.rake
|
239
|
-
- lib/active_record/railties/jdbcmysql_error.rb
|
240
225
|
- lib/active_record/readonly_attributes.rb
|
241
226
|
- lib/active_record/reflection.rb
|
242
227
|
- lib/active_record/relation.rb
|
@@ -249,10 +234,10 @@ files:
|
|
249
234
|
- lib/active_record/relation/merger.rb
|
250
235
|
- lib/active_record/relation/predicate_builder.rb
|
251
236
|
- lib/active_record/relation/predicate_builder/array_handler.rb
|
252
|
-
- lib/active_record/relation/predicate_builder/
|
237
|
+
- lib/active_record/relation/predicate_builder/association_query_value.rb
|
253
238
|
- lib/active_record/relation/predicate_builder/base_handler.rb
|
254
239
|
- lib/active_record/relation/predicate_builder/basic_object_handler.rb
|
255
|
-
- lib/active_record/relation/predicate_builder/
|
240
|
+
- lib/active_record/relation/predicate_builder/polymorphic_array_value.rb
|
256
241
|
- lib/active_record/relation/predicate_builder/range_handler.rb
|
257
242
|
- lib/active_record/relation/predicate_builder/relation_handler.rb
|
258
243
|
- lib/active_record/relation/query_attribute.rb
|
@@ -290,8 +275,8 @@ files:
|
|
290
275
|
- lib/active_record/type/date_time.rb
|
291
276
|
- lib/active_record/type/decimal_without_scale.rb
|
292
277
|
- lib/active_record/type/hash_lookup_type_map.rb
|
293
|
-
- lib/active_record/type/internal/abstract_json.rb
|
294
278
|
- lib/active_record/type/internal/timezone.rb
|
279
|
+
- lib/active_record/type/json.rb
|
295
280
|
- lib/active_record/type/serialized.rb
|
296
281
|
- lib/active_record/type/text.rb
|
297
282
|
- lib/active_record/type/time.rb
|
@@ -308,20 +293,21 @@ files:
|
|
308
293
|
- lib/active_record/validations/uniqueness.rb
|
309
294
|
- lib/active_record/version.rb
|
310
295
|
- lib/rails/generators/active_record.rb
|
296
|
+
- lib/rails/generators/active_record/application_record/application_record_generator.rb
|
297
|
+
- lib/rails/generators/active_record/application_record/templates/application_record.rb.tt
|
311
298
|
- lib/rails/generators/active_record/migration.rb
|
312
299
|
- lib/rails/generators/active_record/migration/migration_generator.rb
|
313
|
-
- lib/rails/generators/active_record/migration/templates/create_table_migration.rb
|
314
|
-
- lib/rails/generators/active_record/migration/templates/migration.rb
|
300
|
+
- lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt
|
301
|
+
- lib/rails/generators/active_record/migration/templates/migration.rb.tt
|
315
302
|
- lib/rails/generators/active_record/model/model_generator.rb
|
316
|
-
- lib/rails/generators/active_record/model/templates/
|
317
|
-
- lib/rails/generators/active_record/model/templates/
|
318
|
-
- lib/rails/generators/active_record/model/templates/module.rb
|
303
|
+
- lib/rails/generators/active_record/model/templates/model.rb.tt
|
304
|
+
- lib/rails/generators/active_record/model/templates/module.rb.tt
|
319
305
|
homepage: http://rubyonrails.org
|
320
306
|
licenses:
|
321
307
|
- MIT
|
322
308
|
metadata:
|
323
|
-
source_code_uri: https://github.com/rails/rails/tree/v5.
|
324
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.
|
309
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.0.beta1/activerecord
|
310
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.0.beta1/activerecord/CHANGELOG.md
|
325
311
|
post_install_message:
|
326
312
|
rdoc_options:
|
327
313
|
- "--main"
|
@@ -335,11 +321,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
335
321
|
version: 2.2.2
|
336
322
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
337
323
|
requirements:
|
338
|
-
- - "
|
324
|
+
- - ">"
|
339
325
|
- !ruby/object:Gem::Version
|
340
|
-
version:
|
326
|
+
version: 1.3.1
|
341
327
|
requirements: []
|
342
|
-
|
328
|
+
rubyforge_project:
|
329
|
+
rubygems_version: 2.6.12
|
343
330
|
signing_key:
|
344
331
|
specification_version: 4
|
345
332
|
summary: Object-relational mapper framework (part of Rails).
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class BelongsTo < SingularAssociation #:nodoc:
|
5
|
-
def association_key_name
|
6
|
-
reflection.options[:primary_key] || klass && klass.primary_key
|
7
|
-
end
|
8
|
-
|
9
|
-
def owner_key_name
|
10
|
-
reflection.foreign_key
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class CollectionAssociation < Association #:nodoc:
|
5
|
-
private
|
6
|
-
|
7
|
-
def preload(preloader)
|
8
|
-
associated_records_by_owner(preloader).each do |owner, records|
|
9
|
-
association = owner.association(reflection.name)
|
10
|
-
association.loaded!
|
11
|
-
association.target.concat(records)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class HasMany < CollectionAssociation #:nodoc:
|
5
|
-
def association_key_name
|
6
|
-
reflection.foreign_key
|
7
|
-
end
|
8
|
-
|
9
|
-
def owner_key_name
|
10
|
-
reflection.active_record_primary_key
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class HasManyThrough < CollectionAssociation #:nodoc:
|
5
|
-
include ThroughAssociation
|
6
|
-
|
7
|
-
def associated_records_by_owner(preloader)
|
8
|
-
records_by_owner = super
|
9
|
-
|
10
|
-
if reflection_scope.distinct_value
|
11
|
-
records_by_owner.each_value(&:uniq!)
|
12
|
-
end
|
13
|
-
|
14
|
-
records_by_owner
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class HasOne < SingularAssociation #:nodoc:
|
5
|
-
def association_key_name
|
6
|
-
reflection.foreign_key
|
7
|
-
end
|
8
|
-
|
9
|
-
def owner_key_name
|
10
|
-
reflection.active_record_primary_key
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
module Associations
|
3
|
-
class Preloader
|
4
|
-
class SingularAssociation < Association #:nodoc:
|
5
|
-
private
|
6
|
-
|
7
|
-
def preload(preloader)
|
8
|
-
associated_records_by_owner(preloader).each do |owner, associated_records|
|
9
|
-
record = associated_records.first
|
10
|
-
|
11
|
-
association = owner.association(reflection.name)
|
12
|
-
association.target = record
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,240 +0,0 @@
|
|
1
|
-
module ActiveRecord
|
2
|
-
class Attribute # :nodoc:
|
3
|
-
class << self
|
4
|
-
def from_database(name, value, type)
|
5
|
-
FromDatabase.new(name, value, type)
|
6
|
-
end
|
7
|
-
|
8
|
-
def from_user(name, value, type, original_attribute = nil)
|
9
|
-
FromUser.new(name, value, type, original_attribute)
|
10
|
-
end
|
11
|
-
|
12
|
-
def with_cast_value(name, value, type)
|
13
|
-
WithCastValue.new(name, value, type)
|
14
|
-
end
|
15
|
-
|
16
|
-
def null(name)
|
17
|
-
Null.new(name)
|
18
|
-
end
|
19
|
-
|
20
|
-
def uninitialized(name, type)
|
21
|
-
Uninitialized.new(name, type)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
attr_reader :name, :value_before_type_cast, :type
|
26
|
-
|
27
|
-
# This method should not be called directly.
|
28
|
-
# Use #from_database or #from_user
|
29
|
-
def initialize(name, value_before_type_cast, type, original_attribute = nil)
|
30
|
-
@name = name
|
31
|
-
@value_before_type_cast = value_before_type_cast
|
32
|
-
@type = type
|
33
|
-
@original_attribute = original_attribute
|
34
|
-
end
|
35
|
-
|
36
|
-
def value
|
37
|
-
# `defined?` is cheaper than `||=` when we get back falsy values
|
38
|
-
@value = type_cast(value_before_type_cast) unless defined?(@value)
|
39
|
-
@value
|
40
|
-
end
|
41
|
-
|
42
|
-
def original_value
|
43
|
-
if assigned?
|
44
|
-
original_attribute.original_value
|
45
|
-
else
|
46
|
-
type_cast(value_before_type_cast)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def value_for_database
|
51
|
-
type.serialize(value)
|
52
|
-
end
|
53
|
-
|
54
|
-
def changed?
|
55
|
-
changed_from_assignment? || changed_in_place?
|
56
|
-
end
|
57
|
-
|
58
|
-
def changed_in_place?
|
59
|
-
has_been_read? && type.changed_in_place?(original_value_for_database, value)
|
60
|
-
end
|
61
|
-
|
62
|
-
def forgetting_assignment
|
63
|
-
with_value_from_database(value_for_database)
|
64
|
-
end
|
65
|
-
|
66
|
-
def with_value_from_user(value)
|
67
|
-
type.assert_valid_value(value)
|
68
|
-
self.class.from_user(name, value, type, original_attribute || self)
|
69
|
-
end
|
70
|
-
|
71
|
-
def with_value_from_database(value)
|
72
|
-
self.class.from_database(name, value, type)
|
73
|
-
end
|
74
|
-
|
75
|
-
def with_cast_value(value)
|
76
|
-
self.class.with_cast_value(name, value, type)
|
77
|
-
end
|
78
|
-
|
79
|
-
def with_type(type)
|
80
|
-
if changed_in_place?
|
81
|
-
with_value_from_user(value).with_type(type)
|
82
|
-
else
|
83
|
-
self.class.new(name, value_before_type_cast, type, original_attribute)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def type_cast(*)
|
88
|
-
raise NotImplementedError
|
89
|
-
end
|
90
|
-
|
91
|
-
def initialized?
|
92
|
-
true
|
93
|
-
end
|
94
|
-
|
95
|
-
def came_from_user?
|
96
|
-
false
|
97
|
-
end
|
98
|
-
|
99
|
-
def has_been_read?
|
100
|
-
defined?(@value)
|
101
|
-
end
|
102
|
-
|
103
|
-
def ==(other)
|
104
|
-
self.class == other.class &&
|
105
|
-
name == other.name &&
|
106
|
-
value_before_type_cast == other.value_before_type_cast &&
|
107
|
-
type == other.type
|
108
|
-
end
|
109
|
-
alias eql? ==
|
110
|
-
|
111
|
-
def hash
|
112
|
-
[self.class, name, value_before_type_cast, type].hash
|
113
|
-
end
|
114
|
-
|
115
|
-
def init_with(coder)
|
116
|
-
@name = coder["name"]
|
117
|
-
@value_before_type_cast = coder["value_before_type_cast"]
|
118
|
-
@type = coder["type"]
|
119
|
-
@original_attribute = coder["original_attribute"]
|
120
|
-
@value = coder["value"] if coder.map.key?("value")
|
121
|
-
end
|
122
|
-
|
123
|
-
def encode_with(coder)
|
124
|
-
coder["name"] = name
|
125
|
-
coder["value_before_type_cast"] = value_before_type_cast unless value_before_type_cast.nil?
|
126
|
-
coder["type"] = type if type
|
127
|
-
coder["original_attribute"] = original_attribute if original_attribute
|
128
|
-
coder["value"] = value if defined?(@value)
|
129
|
-
end
|
130
|
-
|
131
|
-
# TODO Change this to private once we've dropped Ruby 2.2 support.
|
132
|
-
# Workaround for Ruby 2.2 "private attribute?" warning.
|
133
|
-
protected
|
134
|
-
|
135
|
-
attr_reader :original_attribute
|
136
|
-
alias_method :assigned?, :original_attribute
|
137
|
-
|
138
|
-
def original_value_for_database
|
139
|
-
if assigned?
|
140
|
-
original_attribute.original_value_for_database
|
141
|
-
else
|
142
|
-
_original_value_for_database
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
def initialize_dup(other)
|
148
|
-
if defined?(@value) && @value.duplicable?
|
149
|
-
@value = @value.dup
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def changed_from_assignment?
|
154
|
-
assigned? && type.changed?(original_value, value, value_before_type_cast)
|
155
|
-
end
|
156
|
-
|
157
|
-
def _original_value_for_database
|
158
|
-
type.serialize(original_value)
|
159
|
-
end
|
160
|
-
|
161
|
-
class FromDatabase < Attribute # :nodoc:
|
162
|
-
def type_cast(value)
|
163
|
-
type.deserialize(value)
|
164
|
-
end
|
165
|
-
|
166
|
-
def _original_value_for_database
|
167
|
-
value_before_type_cast
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
class FromUser < Attribute # :nodoc:
|
172
|
-
def type_cast(value)
|
173
|
-
type.cast(value)
|
174
|
-
end
|
175
|
-
|
176
|
-
def came_from_user?
|
177
|
-
true
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
class WithCastValue < Attribute # :nodoc:
|
182
|
-
def type_cast(value)
|
183
|
-
value
|
184
|
-
end
|
185
|
-
|
186
|
-
def changed_in_place?
|
187
|
-
false
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
class Null < Attribute # :nodoc:
|
192
|
-
def initialize(name)
|
193
|
-
super(name, nil, Type.default_value)
|
194
|
-
end
|
195
|
-
|
196
|
-
def type_cast(*)
|
197
|
-
nil
|
198
|
-
end
|
199
|
-
|
200
|
-
def with_type(type)
|
201
|
-
self.class.with_cast_value(name, nil, type)
|
202
|
-
end
|
203
|
-
|
204
|
-
def with_value_from_database(value)
|
205
|
-
raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{name}`"
|
206
|
-
end
|
207
|
-
alias_method :with_value_from_user, :with_value_from_database
|
208
|
-
end
|
209
|
-
|
210
|
-
class Uninitialized < Attribute # :nodoc:
|
211
|
-
UNINITIALIZED_ORIGINAL_VALUE = Object.new
|
212
|
-
|
213
|
-
def initialize(name, type)
|
214
|
-
super(name, nil, type)
|
215
|
-
end
|
216
|
-
|
217
|
-
def value
|
218
|
-
if block_given?
|
219
|
-
yield name
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
def original_value
|
224
|
-
UNINITIALIZED_ORIGINAL_VALUE
|
225
|
-
end
|
226
|
-
|
227
|
-
def value_for_database
|
228
|
-
end
|
229
|
-
|
230
|
-
def initialized?
|
231
|
-
false
|
232
|
-
end
|
233
|
-
|
234
|
-
def with_type(type)
|
235
|
-
self.class.new(name, type)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
private_constant :FromDatabase, :FromUser, :Null, :Uninitialized, :WithCastValue
|
239
|
-
end
|
240
|
-
end
|