activerecord 5.0.7.2 → 6.0.3.4
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 +708 -2040
- data/MIT-LICENSE +3 -1
- data/README.rdoc +9 -7
- data/examples/performance.rb +31 -29
- data/examples/simple.rb +5 -3
- data/lib/active_record.rb +37 -22
- data/lib/active_record/advisory_lock_base.rb +18 -0
- data/lib/active_record/aggregations.rb +249 -247
- data/lib/active_record/association_relation.rb +18 -14
- data/lib/active_record/associations.rb +1603 -1592
- data/lib/active_record/associations/alias_tracker.rb +24 -34
- data/lib/active_record/associations/association.rb +114 -55
- data/lib/active_record/associations/association_scope.rb +94 -94
- data/lib/active_record/associations/belongs_to_association.rb +58 -42
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -12
- data/lib/active_record/associations/builder/association.rb +18 -25
- data/lib/active_record/associations/builder/belongs_to.rb +43 -54
- data/lib/active_record/associations/builder/collection_association.rb +7 -18
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +41 -62
- data/lib/active_record/associations/builder/has_many.rb +4 -0
- data/lib/active_record/associations/builder/has_one.rb +37 -1
- data/lib/active_record/associations/builder/singular_association.rb +4 -0
- data/lib/active_record/associations/collection_association.rb +86 -254
- data/lib/active_record/associations/collection_proxy.rb +158 -122
- data/lib/active_record/associations/foreign_association.rb +9 -0
- data/lib/active_record/associations/has_many_association.rb +23 -30
- data/lib/active_record/associations/has_many_through_association.rb +58 -44
- data/lib/active_record/associations/has_one_association.rb +59 -54
- data/lib/active_record/associations/has_one_through_association.rb +20 -11
- data/lib/active_record/associations/join_dependency.rb +143 -176
- data/lib/active_record/associations/join_dependency/join_association.rb +38 -87
- data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
- data/lib/active_record/associations/join_dependency/join_part.rb +12 -12
- data/lib/active_record/associations/preloader.rb +90 -103
- data/lib/active_record/associations/preloader/association.rb +86 -100
- data/lib/active_record/associations/preloader/through_association.rb +77 -76
- data/lib/active_record/associations/singular_association.rb +12 -45
- data/lib/active_record/associations/through_association.rb +26 -14
- data/lib/active_record/attribute_assignment.rb +54 -61
- data/lib/active_record/attribute_decorators.rb +38 -17
- data/lib/active_record/attribute_methods.rb +66 -106
- data/lib/active_record/attribute_methods/before_type_cast.rb +12 -8
- data/lib/active_record/attribute_methods/dirty.rb +179 -109
- data/lib/active_record/attribute_methods/primary_key.rb +85 -92
- data/lib/active_record/attribute_methods/query.rb +4 -3
- data/lib/active_record/attribute_methods/read.rb +20 -49
- data/lib/active_record/attribute_methods/serialization.rb +29 -7
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +39 -66
- data/lib/active_record/attribute_methods/write.rb +34 -33
- data/lib/active_record/attributes.rb +38 -25
- data/lib/active_record/autosave_association.rb +54 -35
- data/lib/active_record/base.rb +27 -24
- data/lib/active_record/callbacks.rb +64 -35
- data/lib/active_record/coders/json.rb +2 -0
- data/lib/active_record/coders/yaml_column.rb +11 -12
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +552 -323
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +23 -5
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +215 -94
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +59 -35
- data/lib/active_record/connection_adapters/abstract/quoting.rb +119 -75
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +2 -0
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +33 -28
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +228 -147
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +68 -80
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +400 -213
- data/lib/active_record/connection_adapters/abstract/transaction.rb +169 -79
- data/lib/active_record/connection_adapters/abstract_adapter.rb +367 -202
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +396 -562
- data/lib/active_record/connection_adapters/column.rb +41 -13
- data/lib/active_record/connection_adapters/connection_specification.rb +172 -139
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +11 -4
- data/lib/active_record/connection_adapters/mysql/column.rb +8 -31
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +137 -49
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +24 -23
- data/lib/active_record/connection_adapters/mysql/quoting.rb +50 -20
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +49 -45
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +58 -56
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +70 -36
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +264 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +12 -13
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +48 -30
- data/lib/active_record/connection_adapters/postgresql/column.rb +19 -31
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +64 -54
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid.rb +24 -21
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +22 -11
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +6 -5
- 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 +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +23 -0
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/decimal.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +5 -4
- data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +19 -18
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb +3 -11
- data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +7 -5
- data/lib/active_record/connection_adapters/postgresql/oid/{json.rb → oid.rb} +6 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +30 -9
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +34 -31
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -1
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +58 -54
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +8 -4
- 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 +95 -35
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +20 -26
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +76 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +147 -105
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +34 -32
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +378 -308
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +26 -25
- data/lib/active_record/connection_adapters/postgresql/utils.rb +9 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +383 -275
- data/lib/active_record/connection_adapters/schema_cache.rb +46 -12
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +13 -8
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +119 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +3 -1
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +72 -18
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +3 -8
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +137 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +259 -266
- data/lib/active_record/connection_adapters/statement_pool.rb +9 -8
- data/lib/active_record/connection_handling.rb +143 -40
- data/lib/active_record/core.rb +201 -163
- data/lib/active_record/counter_cache.rb +60 -28
- data/lib/active_record/database_configurations.rb +233 -0
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +78 -0
- data/lib/active_record/define_callbacks.rb +22 -0
- data/lib/active_record/dynamic_matchers.rb +87 -87
- data/lib/active_record/enum.rb +60 -23
- data/lib/active_record/errors.rb +114 -18
- data/lib/active_record/explain.rb +4 -4
- data/lib/active_record/explain_registry.rb +3 -1
- data/lib/active_record/explain_subscriber.rb +9 -4
- data/lib/active_record/fixture_set/file.rb +13 -8
- data/lib/active_record/fixture_set/model_metadata.rb +33 -0
- data/lib/active_record/fixture_set/render_context.rb +17 -0
- data/lib/active_record/fixture_set/table_row.rb +152 -0
- data/lib/active_record/fixture_set/table_rows.rb +46 -0
- data/lib/active_record/fixtures.rb +194 -504
- data/lib/active_record/gem_version.rb +5 -3
- data/lib/active_record/inheritance.rb +150 -99
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +116 -25
- data/lib/active_record/internal_metadata.rb +16 -19
- data/lib/active_record/legacy_yaml_adapter.rb +4 -2
- data/lib/active_record/locking/optimistic.rb +77 -87
- data/lib/active_record/locking/pessimistic.rb +18 -6
- data/lib/active_record/log_subscriber.rb +48 -29
- data/lib/active_record/middleware/database_selector.rb +74 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +87 -0
- data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
- data/lib/active_record/migration.rb +369 -302
- data/lib/active_record/migration/command_recorder.rb +134 -100
- data/lib/active_record/migration/compatibility.rb +174 -56
- data/lib/active_record/migration/join_table.rb +8 -7
- data/lib/active_record/model_schema.rb +131 -127
- data/lib/active_record/nested_attributes.rb +213 -202
- data/lib/active_record/no_touching.rb +12 -3
- data/lib/active_record/null_relation.rb +12 -34
- data/lib/active_record/persistence.rb +446 -77
- data/lib/active_record/query_cache.rb +13 -12
- data/lib/active_record/querying.rb +37 -24
- data/lib/active_record/railtie.rb +128 -36
- data/lib/active_record/railties/collection_cache_association_loading.rb +34 -0
- data/lib/active_record/railties/console_sandbox.rb +2 -0
- data/lib/active_record/railties/controller_runtime.rb +34 -33
- data/lib/active_record/railties/databases.rake +312 -177
- data/lib/active_record/readonly_attributes.rb +5 -4
- data/lib/active_record/reflection.rb +214 -252
- data/lib/active_record/relation.rb +440 -318
- data/lib/active_record/relation/batches.rb +98 -52
- data/lib/active_record/relation/batches/batch_enumerator.rb +3 -1
- data/lib/active_record/relation/calculations.rb +212 -173
- data/lib/active_record/relation/delegation.rb +72 -69
- data/lib/active_record/relation/finder_methods.rb +207 -247
- data/lib/active_record/relation/from_clause.rb +6 -8
- data/lib/active_record/relation/merger.rb +78 -62
- data/lib/active_record/relation/predicate_builder.rb +83 -105
- data/lib/active_record/relation/predicate_builder/array_handler.rb +20 -14
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +43 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +4 -3
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +6 -4
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +53 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +7 -18
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +6 -0
- data/lib/active_record/relation/query_attribute.rb +33 -2
- data/lib/active_record/relation/query_methods.rb +476 -334
- data/lib/active_record/relation/record_fetch_warning.rb +5 -3
- data/lib/active_record/relation/spawn_methods.rb +8 -8
- data/lib/active_record/relation/where_clause.rb +111 -96
- data/lib/active_record/relation/where_clause_factory.rb +6 -11
- data/lib/active_record/result.rb +69 -40
- data/lib/active_record/runtime_registry.rb +5 -3
- data/lib/active_record/sanitization.rb +83 -99
- data/lib/active_record/schema.rb +7 -14
- data/lib/active_record/schema_dumper.rb +71 -69
- data/lib/active_record/schema_migration.rb +16 -6
- data/lib/active_record/scoping.rb +20 -20
- data/lib/active_record/scoping/default.rb +92 -95
- data/lib/active_record/scoping/named.rb +47 -27
- data/lib/active_record/secure_token.rb +4 -2
- data/lib/active_record/serialization.rb +2 -0
- data/lib/active_record/statement_cache.rb +63 -28
- data/lib/active_record/store.rb +121 -41
- data/lib/active_record/suppressor.rb +6 -3
- data/lib/active_record/table_metadata.rb +39 -18
- data/lib/active_record/tasks/database_tasks.rb +271 -81
- data/lib/active_record/tasks/mysql_database_tasks.rb +54 -91
- data/lib/active_record/tasks/postgresql_database_tasks.rb +77 -47
- data/lib/active_record/tasks/sqlite_database_tasks.rb +33 -16
- data/lib/active_record/test_databases.rb +23 -0
- data/lib/active_record/test_fixtures.rb +225 -0
- data/lib/active_record/timestamp.rb +70 -36
- data/lib/active_record/touch_later.rb +8 -6
- data/lib/active_record/transactions.rb +141 -157
- data/lib/active_record/translation.rb +3 -1
- data/lib/active_record/type.rb +23 -18
- data/lib/active_record/type/adapter_specific_registry.rb +44 -48
- 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 +15 -0
- data/lib/active_record/type/hash_lookup_type_map.rb +5 -4
- 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 +16 -9
- data/lib/active_record/type/text.rb +11 -0
- data/lib/active_record/type/time.rb +2 -1
- data/lib/active_record/type/type_map.rb +14 -17
- data/lib/active_record/type/unsigned_integer.rb +16 -0
- data/lib/active_record/type_caster.rb +4 -2
- data/lib/active_record/type_caster/connection.rb +17 -12
- data/lib/active_record/type_caster/map.rb +5 -4
- data/lib/active_record/validations.rb +7 -5
- data/lib/active_record/validations/absence.rb +2 -0
- data/lib/active_record/validations/associated.rb +4 -3
- data/lib/active_record/validations/length.rb +2 -0
- data/lib/active_record/validations/presence.rb +4 -2
- data/lib/active_record/validations/uniqueness.rb +29 -42
- data/lib/active_record/version.rb +3 -1
- data/lib/arel.rb +62 -0
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes.rb +68 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +67 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +45 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values_list.rb +9 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +256 -0
- data/lib/arel/select_manager.rb +271 -0
- data/lib/arel/table.rb +110 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors.rb +20 -0
- data/lib/arel/visitors/depth_first.rb +203 -0
- data/lib/arel/visitors/dot.rb +296 -0
- data/lib/arel/visitors/ibm_db.rb +34 -0
- data/lib/arel/visitors/informix.rb +62 -0
- data/lib/arel/visitors/mssql.rb +156 -0
- data/lib/arel/visitors/mysql.rb +83 -0
- data/lib/arel/visitors/oracle.rb +158 -0
- data/lib/arel/visitors/oracle12.rb +65 -0
- data/lib/arel/visitors/postgresql.rb +109 -0
- data/lib/arel/visitors/sqlite.rb +38 -0
- data/lib/arel/visitors/to_sql.rb +888 -0
- data/lib/arel/visitors/visitor.rb +45 -0
- data/lib/arel/visitors/where_sql.rb +22 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/rails/generators/active_record.rb +7 -5
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +26 -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 +17 -3
- data/lib/rails/generators/active_record/migration/migration_generator.rb +37 -35
- data/lib/rails/generators/active_record/migration/templates/{create_table_migration.rb → create_table_migration.rb.tt} +1 -1
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +4 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +9 -30
- data/lib/rails/generators/active_record/model/templates/{model.rb → model.rb.tt} +10 -1
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- metadata +137 -52
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -17
- data/lib/active_record/associations/preloader/has_many.rb +0 -17
- 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 -20
- data/lib/active_record/attribute.rb +0 -213
- data/lib/active_record/attribute/user_provided_default.rb +0 -28
- data/lib/active_record/attribute_mutation_tracker.rb +0 -70
- data/lib/active_record/attribute_set.rb +0 -110
- data/lib/active_record/attribute_set/builder.rb +0 -132
- data/lib/active_record/collection_cache_key.rb +0 -50
- data/lib/active_record/connection_adapters/postgresql/oid/rails_5_1_point.rb +0 -50
- 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/class_handler.rb +0 -27
- data/lib/active_record/relation/predicate_builder/polymorphic_array_handler.rb +0 -57
- data/lib/active_record/type/internal/abstract_json.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140f6f368f1117ee61cd524faca9684ae30de2683f916da86fc5d407a7745cca
|
4
|
+
data.tar.gz: e4c73cf6172c0d17caaf5f4d705e4a4ebff642d0db70c3a70b67f98b8f60b5c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef0ee3b5b549012bf375144e37e33ca1061dfdd6c2b2a95b4dddf97e42260f7127b64f2d34cf48ac6a532a33b84bff16db6a5bc7263f18773db71a347c13ea01
|
7
|
+
data.tar.gz: 4fc23dcaa4cd671863cf194f6d8ab9673353e4b78f647224b25a76b00d947cc740f00a89c78ecd55384c9d3146f183f5bd1d756ec3e99c5794047ab068d05d8b
|
data/CHANGELOG.md
CHANGED
@@ -1,2549 +1,1217 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 6.0.3.4 (October 07, 2020) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 6.0.3.3 (September 09, 2020) ##
|
7
7
|
|
8
8
|
* No changes.
|
9
9
|
|
10
10
|
|
11
|
-
## Rails
|
11
|
+
## Rails 6.0.3.2 (June 17, 2020) ##
|
12
12
|
|
13
|
-
*
|
13
|
+
* No changes.
|
14
14
|
|
15
|
-
PR #20317 changed the behavior of datetime columns so that when they
|
16
|
-
have a specified precision then on assignment the value is rounded to
|
17
|
-
that precision. This behavior is now applied to time columns as well.
|
18
15
|
|
19
|
-
|
16
|
+
## Rails 6.0.3.1 (May 18, 2020) ##
|
20
17
|
|
21
|
-
|
18
|
+
* No changes.
|
22
19
|
|
23
|
-
* Normalize time column values for SQLite database.
|
24
20
|
|
25
|
-
|
26
|
-
because until #24542 the quoting for time columns didn't remove the date
|
27
|
-
component. To ensure that values are consistent we now normalize the
|
28
|
-
date component to 2001-01-01 on reading and writing.
|
21
|
+
## Rails 6.0.3 (May 06, 2020) ##
|
29
22
|
|
30
|
-
|
23
|
+
* Recommend applications don't use the `database` kwarg in `connected_to`
|
31
24
|
|
32
|
-
|
25
|
+
The database kwarg in `connected_to` was meant to be used for one-off scripts but is often used in requests. This is really dangerous because it re-establishes a connection every time. It's deprecated in 6.1 and will be removed in 6.2 without replacement. This change soft deprecates it in 6.0 by removing documentation.
|
33
26
|
|
34
|
-
|
35
|
-
was removed however it only removed it when it was 2001-01-01. Now the
|
36
|
-
date component is removed irrespective of what the date is.
|
27
|
+
*Eileen M. Uchitelle*
|
37
28
|
|
38
|
-
|
29
|
+
* Fix support for PostgreSQL 11+ partitioned indexes.
|
39
30
|
|
40
|
-
*
|
41
|
-
without being connected.
|
31
|
+
*Sebastián Palma*
|
42
32
|
|
43
|
-
|
33
|
+
* Add support for beginless ranges, introduced in Ruby 2.7.
|
44
34
|
|
45
|
-
*
|
46
|
-
ar_internal_metadata's data for a test database.
|
35
|
+
*Josh Goodall*
|
47
36
|
|
48
|
-
|
49
|
-
```
|
50
|
-
$ RAILS_ENV=test rails dbconsole
|
51
|
-
> SELECT * FROM ar_internal_metadata;
|
52
|
-
key|value|created_at|updated_at
|
53
|
-
environment|development|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
54
|
-
```
|
37
|
+
* Fix insert_all with enum values
|
55
38
|
|
56
|
-
|
57
|
-
```
|
58
|
-
$ RAILS_ENV=test rails dbconsole
|
59
|
-
> SELECT * FROM ar_internal_metadata;
|
60
|
-
key|value|created_at|updated_at
|
61
|
-
environment|test|2017-09-11 23:14:10.815679|2017-09-11 23:14:10.815679
|
62
|
-
```
|
39
|
+
Fixes #38716.
|
63
40
|
|
64
|
-
|
41
|
+
*Joel Blum*
|
65
42
|
|
66
|
-
|
43
|
+
* Regexp-escape table name for MS SQL
|
67
44
|
|
68
|
-
|
45
|
+
Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
|
69
46
|
|
70
|
-
|
47
|
+
*Larry Reid*
|
71
48
|
|
72
|
-
|
49
|
+
* Store advisory locks on their own named connection.
|
73
50
|
|
74
|
-
|
51
|
+
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
75
52
|
|
76
|
-
|
53
|
+
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
77
54
|
|
55
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
78
56
|
|
79
|
-
|
57
|
+
* Ensure `:reading` connections always raise if a write is attempted.
|
80
58
|
|
81
|
-
|
59
|
+
Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
|
82
60
|
|
61
|
+
*Eileen M. Uchitelle*
|
83
62
|
|
84
|
-
|
63
|
+
* Enforce fresh ETag header after a collection's contents change by adding
|
64
|
+
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
65
|
+
ActionController::ConditionalGet to ensure that when collection cache versioning
|
66
|
+
is enabled, requests using ConditionalGet don't return the same ETag header
|
67
|
+
after a collection is modified. Fixes #38078.
|
85
68
|
|
86
|
-
*
|
69
|
+
*Aaron Lipman*
|
87
70
|
|
88
|
-
|
71
|
+
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
|
89
72
|
|
90
|
-
|
73
|
+
*Joshua Flanagan*
|
91
74
|
|
75
|
+
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
92
76
|
|
93
|
-
|
77
|
+
Resolves #34889.
|
94
78
|
|
95
|
-
*
|
79
|
+
*Patrick Rebsch*
|
96
80
|
|
97
81
|
|
98
|
-
## Rails
|
82
|
+
## Rails 6.0.2.2 (March 19, 2020) ##
|
99
83
|
|
100
84
|
* No changes.
|
101
85
|
|
102
86
|
|
103
|
-
## Rails
|
104
|
-
|
105
|
-
* `Relation#joins` is no longer affected by the target model's
|
106
|
-
`current_scope`, with the exception of `unscoped`.
|
107
|
-
|
108
|
-
Fixes #29338.
|
109
|
-
|
110
|
-
*Sean Griffin*
|
87
|
+
## Rails 6.0.2.1 (December 18, 2019) ##
|
111
88
|
|
89
|
+
* No changes.
|
112
90
|
|
113
|
-
## Rails 5.0.4 (June 19, 2017) ##
|
114
91
|
|
115
|
-
|
116
|
-
methods stubbed, and they respect extension modules applied by a default
|
117
|
-
scope.
|
92
|
+
## Rails 6.0.2 (December 13, 2019) ##
|
118
93
|
|
119
|
-
|
94
|
+
* Share the same connection pool for primary and replica databases in the
|
95
|
+
transactional tests for the same database.
|
120
96
|
|
121
|
-
*
|
97
|
+
*Edouard Chin*
|
122
98
|
|
123
|
-
|
99
|
+
* Fix the preloader when one record is fetched using `after_initialize`
|
100
|
+
but not the entire collection.
|
124
101
|
|
125
|
-
*
|
102
|
+
*Bradley Price*
|
126
103
|
|
104
|
+
* Fix collection callbacks not terminating when `:abort` is thrown.
|
127
105
|
|
128
|
-
|
106
|
+
*Edouard Chin*, *Ryuta Kamizono*
|
129
107
|
|
130
|
-
*
|
108
|
+
* Correctly deprecate `where.not` working as NOR for relations.
|
131
109
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
of the context of a Rails application.
|
110
|
+
12a9664 deprecated where.not working as NOR, however
|
111
|
+
doing a relation query like `where.not(relation: { ... })`
|
112
|
+
wouldn't be properly deprecated and `where.not` would work as
|
113
|
+
NAND instead.
|
137
114
|
|
138
|
-
|
115
|
+
*Edouard Chin*
|
139
116
|
|
140
|
-
* Fix `
|
117
|
+
* Fix `db:migrate` task with multiple databases to restore the connection
|
118
|
+
to the previous database.
|
141
119
|
|
142
|
-
|
120
|
+
The migrate task iterates and establish a connection over each db
|
121
|
+
resulting in the last one to be used by subsequent rake tasks.
|
122
|
+
We should reestablish a connection to the connection that was
|
123
|
+
established before the migrate tasks was run
|
143
124
|
|
144
|
-
*
|
125
|
+
*Edouard Chin*
|
145
126
|
|
146
|
-
* Fix
|
127
|
+
* Fix multi-threaded issue for `AcceptanceValidator`.
|
147
128
|
|
148
129
|
*Ryuta Kamizono*
|
149
130
|
|
150
|
-
* Fix `rake db:migrate:status` with subdirectories.
|
151
|
-
|
152
|
-
*Ryuta Kamizono*
|
153
131
|
|
154
|
-
|
132
|
+
## Rails 6.0.1 (November 5, 2019) ##
|
155
133
|
|
156
|
-
|
157
|
-
between the two columns doesn't make sense since they are different types.
|
158
|
-
The `reference_id` column is usually an integer and the `reference_type`
|
159
|
-
column a string so options like `unsigned: true` will result in an invalid
|
160
|
-
table definition.
|
134
|
+
* Common Table Expressions are allowed on read-only connections.
|
161
135
|
|
162
|
-
|
136
|
+
*Chris Morris*
|
163
137
|
|
164
|
-
*
|
138
|
+
* New record instantiation respects `unscope`.
|
165
139
|
|
166
|
-
|
140
|
+
*Ryuta Kamizono*
|
167
141
|
|
142
|
+
* Fixed a case where `find_in_batches` could halt too early.
|
168
143
|
|
169
|
-
|
144
|
+
*Takayuki Nakata*
|
170
145
|
|
171
|
-
*
|
146
|
+
* Autosaved associations always perform validations when a custom validation
|
147
|
+
context is used.
|
172
148
|
|
173
|
-
|
149
|
+
*Tekin Suleyman*
|
174
150
|
|
175
|
-
|
151
|
+
* `sql.active_record` notifications now include the `:connection` in
|
152
|
+
their payloads.
|
176
153
|
|
177
|
-
*
|
178
|
-
so queries are not run against the previous table name.
|
154
|
+
*Eugene Kenny*
|
179
155
|
|
180
|
-
|
156
|
+
* A rollback encountered in an `after_commit` callback does not reset
|
157
|
+
previously-committed record state.
|
181
158
|
|
182
|
-
*
|
159
|
+
*Ryuta Kamizono*
|
183
160
|
|
184
|
-
|
161
|
+
* Fixed that join order was lost when eager-loading.
|
185
162
|
|
186
|
-
*
|
163
|
+
*Ryuta Kamizono*
|
187
164
|
|
188
|
-
|
165
|
+
* `DESCRIBE` queries are allowed on read-only connections.
|
189
166
|
|
190
|
-
*
|
167
|
+
*Dylan Thacker-Smith*
|
191
168
|
|
192
|
-
|
169
|
+
* Fixed that records that had been `inspect`ed could not be marshaled.
|
193
170
|
|
194
|
-
*
|
171
|
+
*Eugene Kenny*
|
195
172
|
|
196
|
-
*
|
173
|
+
* The connection pool reaper thread is respawned in forked processes. This
|
174
|
+
fixes that idle connections in forked processes wouldn't be reaped.
|
197
175
|
|
198
|
-
*
|
176
|
+
*John Hawthorn*
|
199
177
|
|
200
|
-
*
|
201
|
-
|
178
|
+
* The memoized result of `ActiveRecord::Relation#take` is properly cleared
|
179
|
+
when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
|
180
|
+
is called.
|
202
181
|
|
203
|
-
|
182
|
+
*Anmol Arora*
|
204
183
|
|
205
|
-
|
184
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
206
185
|
|
207
|
-
*
|
186
|
+
*Hiroyuki Ishii*
|
208
187
|
|
209
|
-
|
188
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
210
189
|
|
211
|
-
*
|
190
|
+
*Eugene Kenny*
|
212
191
|
|
192
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
213
193
|
|
214
|
-
|
194
|
+
In some cases application authors want to use the database switching middleware and make explicit calls with `connected_to`. It's possible for an app to turn off writes and not turn them back on by the time we call `connected_to(role: :writing)`.
|
215
195
|
|
216
|
-
|
196
|
+
This change allows apps to fix this by assuming if a role is writing we want to allow writes, except in the case it's explicitly turned off.
|
217
197
|
|
198
|
+
*Eileen M. Uchitelle*
|
218
199
|
|
219
|
-
|
200
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
220
201
|
|
221
|
-
*
|
222
|
-
associations' `*_ids` setters.
|
202
|
+
*Kir Shatrov*
|
223
203
|
|
224
|
-
Fixes #27297.
|
225
204
|
|
226
|
-
|
205
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
227
206
|
|
228
|
-
*
|
229
|
-
column names.
|
207
|
+
* Preserve user supplied joins order as much as possible.
|
230
208
|
|
231
|
-
Fixes #
|
209
|
+
Fixes #36761, #34328, #24281, #12953.
|
232
210
|
|
233
211
|
*Ryuta Kamizono*
|
234
212
|
|
213
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
235
214
|
|
236
|
-
|
237
|
-
|
238
|
-
* Fix that unsigned with zerofill is treated as signed.
|
239
|
-
|
240
|
-
Fixes #27125.
|
215
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
241
216
|
|
242
|
-
|
243
|
-
|
244
|
-
* Fix the uniqueness validation scope with a polymorphic association.
|
217
|
+
* Add a warning for enum elements with 'not_' prefix.
|
245
218
|
|
246
|
-
|
219
|
+
class Foo
|
220
|
+
enum status: [:sent, :not_sent]
|
221
|
+
end
|
247
222
|
|
248
|
-
*
|
249
|
-
for unknown IDs with a better error message.
|
223
|
+
*Edu Depetris*
|
250
224
|
|
251
|
-
|
252
|
-
type of the primary key set in the association, not the model
|
253
|
-
primary key.
|
225
|
+
* Make currency symbols optional for money column type in PostgreSQL
|
254
226
|
|
255
|
-
*
|
227
|
+
*Joel Schneider*
|
256
228
|
|
257
|
-
* Introduce `Model#reload_<association>` to bring back the behavior
|
258
|
-
of `Article.category(true)` where `category` is a singular
|
259
|
-
association.
|
260
229
|
|
261
|
-
|
262
|
-
in #20888. Unfortunately the suggested alternative of
|
263
|
-
`article.reload.category` does not expose the same behavior.
|
230
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
264
231
|
|
265
|
-
|
266
|
-
singular associations. This method has the same semantics as
|
267
|
-
passing true to the association reader used to have.
|
232
|
+
* Add database_exists? method to connection adapters to check if a database exists.
|
268
233
|
|
269
|
-
*
|
234
|
+
*Guilherme Mansur*
|
270
235
|
|
271
|
-
*
|
272
|
-
constants defined in `ActiveRecord::Associations::Preloader`.
|
236
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
273
237
|
|
274
|
-
|
238
|
+
Fixes #36022.
|
275
239
|
|
276
|
-
*
|
277
|
-
values for Postgres HStore columns.
|
240
|
+
*Ryuta Kamizono*
|
278
241
|
|
279
|
-
|
242
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
280
243
|
|
281
|
-
|
244
|
+
Fixes #36465.
|
282
245
|
|
283
|
-
*
|
246
|
+
*Jeff Doering*
|
284
247
|
|
285
|
-
|
286
|
-
until it's actually needed.
|
248
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
287
249
|
|
288
|
-
|
289
|
-
cache may notice that the connection's cache is now cleared and disabled
|
290
|
-
when it gets returned to the pool, even if the request is not yet completed.
|
250
|
+
*Martin R. Schuster*
|
291
251
|
|
292
|
-
|
252
|
+
* Fix invalid schema when primary key column has a comment.
|
293
253
|
|
294
|
-
|
295
|
-
PostgreSQL.
|
254
|
+
Fixes #29966.
|
296
255
|
|
297
|
-
*
|
256
|
+
*Guilherme Goettems Schneider*
|
298
257
|
|
299
|
-
*
|
300
|
-
to be updated is unchanged.
|
258
|
+
* Fix table comment also being applied to the primary key column.
|
301
259
|
|
302
|
-
|
260
|
+
*Guilherme Goettems Schneider*
|
303
261
|
|
304
|
-
|
262
|
+
* Fix merging left_joins to maintain its own `join_type` context.
|
305
263
|
|
306
|
-
|
264
|
+
Fixes #36103.
|
307
265
|
|
308
|
-
*
|
266
|
+
*Ryuta Kamizono*
|
309
267
|
|
310
|
-
* Always store errors details information with symbols.
|
311
268
|
|
312
|
-
|
313
|
-
string keys. This was creating inconsistency with other details that are
|
314
|
-
added using the `Errors#add` method. It was also inconsistent with the
|
315
|
-
`Errors#messages` storage.
|
269
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
316
270
|
|
317
|
-
|
318
|
-
cause a small breaking change because in those cases the details could
|
319
|
-
be accessed as strings keys but now it can not.
|
271
|
+
* Add `touch` option to `has_one` association.
|
320
272
|
|
321
|
-
|
273
|
+
*Abhay Nikam*
|
322
274
|
|
323
|
-
|
275
|
+
* Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
|
324
276
|
|
325
|
-
|
326
|
-
|
277
|
+
```ruby
|
278
|
+
all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
|
279
|
+
assert_equal all, PriceEstimate.all.map(&:estimate_of)
|
280
|
+
```
|
327
281
|
|
328
|
-
|
282
|
+
In Rails 6.0:
|
329
283
|
|
330
|
-
|
331
|
-
|
284
|
+
```ruby
|
285
|
+
sapphire = treasures(:sapphire)
|
332
286
|
|
333
|
-
|
287
|
+
nor = all.reject { |e|
|
288
|
+
e.estimate_of_type == sapphire.class.polymorphic_name
|
289
|
+
}.reject { |e|
|
290
|
+
e.estimate_of_id == sapphire.id
|
291
|
+
}
|
292
|
+
assert_equal [cars(:honda)], nor
|
334
293
|
|
335
|
-
|
336
|
-
|
294
|
+
without_sapphire = PriceEstimate.where.not(
|
295
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
296
|
+
)
|
297
|
+
assert_equal nor, without_sapphire.map(&:estimate_of)
|
298
|
+
```
|
337
299
|
|
338
|
-
|
300
|
+
In Rails 6.1:
|
339
301
|
|
340
|
-
|
302
|
+
```ruby
|
303
|
+
sapphire = treasures(:sapphire)
|
341
304
|
|
342
|
-
|
343
|
-
|
305
|
+
nand = all - [sapphire]
|
306
|
+
assert_equal [treasures(:diamond), cars(:honda)], nand
|
344
307
|
|
345
|
-
|
308
|
+
without_sapphire = PriceEstimate.where.not(
|
309
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
310
|
+
)
|
311
|
+
assert_equal nand, without_sapphire.map(&:estimate_of)
|
312
|
+
```
|
346
313
|
|
347
|
-
*
|
314
|
+
*Ryuta Kamizono*
|
348
315
|
|
349
|
-
*
|
350
|
-
the `pluck` method on a collection.
|
316
|
+
* Fix dirty tracking after rollback.
|
351
317
|
|
352
|
-
Fixes #
|
318
|
+
Fixes #15018, #30167, #33868.
|
353
319
|
|
354
320
|
*Ryuta Kamizono*
|
355
321
|
|
356
|
-
*
|
357
|
-
|
358
|
-
|
322
|
+
* Add `ActiveRecord::Relation#cache_version` to support recyclable cache keys via
|
323
|
+
the versioned entries in `ActiveSupport::Cache`. This also means that
|
324
|
+
`ActiveRecord::Relation#cache_key` will now return a stable key that does not
|
325
|
+
include the max timestamp or count any more.
|
359
326
|
|
360
|
-
|
327
|
+
NOTE: This feature is turned off by default, and `cache_key` will still return
|
328
|
+
cache keys with timestamps until you set `ActiveRecord::Base.collection_cache_versioning = true`.
|
329
|
+
That's the setting for all new apps on Rails 6.0+
|
361
330
|
|
362
|
-
*
|
331
|
+
*Lachlan Sylvester*
|
363
332
|
|
364
|
-
*
|
365
|
-
mapping methods are methods implemented on `Hash`.
|
333
|
+
* Fix dirty tracking for `touch` to track saved changes.
|
366
334
|
|
367
|
-
Fixes #
|
335
|
+
Fixes #33429.
|
368
336
|
|
369
|
-
*
|
337
|
+
*Ryuta Kamzono*
|
370
338
|
|
371
|
-
*
|
372
|
-
|
339
|
+
* `change_column_comment` and `change_table_comment` are invertible only if
|
340
|
+
`to` and `from` options are specified.
|
373
341
|
|
374
|
-
*
|
342
|
+
*Yoshiyuki Kinjo*
|
375
343
|
|
376
|
-
*
|
377
|
-
`model` methods to be consistent with RecordNotFound raised by Record.find.
|
344
|
+
* Don't call commit/rollback callbacks when a record isn't saved.
|
378
345
|
|
379
|
-
|
346
|
+
Fixes #29747.
|
380
347
|
|
381
|
-
*
|
348
|
+
*Ryuta Kamizono*
|
382
349
|
|
383
|
-
|
350
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
384
351
|
|
385
|
-
|
386
|
-
|
352
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
353
|
+
associations, the callback for a `has_many` association was run while
|
354
|
+
another instance of the same callback on the same association hadn't
|
355
|
+
finished running. When control returned to the first instance of the
|
356
|
+
callback, the instance variable had changed, and subsequent associated
|
357
|
+
records weren't saved correctly. Specifically, the ID field for the
|
358
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
387
359
|
|
388
|
-
|
360
|
+
Fixes #28080.
|
389
361
|
|
390
|
-
*
|
362
|
+
*Larry Reid*
|
391
363
|
|
392
|
-
|
364
|
+
* Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options.
|
393
365
|
|
394
|
-
|
366
|
+
Before:
|
395
367
|
|
396
|
-
|
397
|
-
|
368
|
+
```ruby
|
369
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
370
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
371
|
+
add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
|
372
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
|
373
|
+
```
|
398
374
|
|
399
|
-
|
375
|
+
After:
|
400
376
|
|
401
|
-
|
402
|
-
|
377
|
+
```ruby
|
378
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
379
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
380
|
+
add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
|
381
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
|
382
|
+
```
|
403
383
|
|
404
|
-
|
384
|
+
*Ryuta Kamizono*
|
405
385
|
|
406
|
-
|
386
|
+
* Association loading isn't to be affected by scoping consistently
|
387
|
+
whether preloaded / eager loaded or not, with the exception of `unscoped`.
|
407
388
|
|
408
|
-
|
409
|
-
same connection to two threads.
|
389
|
+
Before:
|
410
390
|
|
411
|
-
|
391
|
+
```ruby
|
392
|
+
Post.where("1=0").scoping do
|
393
|
+
Comment.find(1).post # => nil
|
394
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
395
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
396
|
+
end
|
397
|
+
```
|
412
398
|
|
413
|
-
|
399
|
+
After:
|
414
400
|
|
415
|
-
|
416
|
-
|
401
|
+
```ruby
|
402
|
+
Post.where("1=0").scoping do
|
403
|
+
Comment.find(1).post # => #<Post id: 1, ...>
|
404
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
405
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
406
|
+
end
|
407
|
+
```
|
417
408
|
|
418
|
-
Fixes #
|
409
|
+
Fixes #34638, #35398.
|
419
410
|
|
420
411
|
*Ryuta Kamizono*
|
421
412
|
|
413
|
+
* Add `rails db:prepare` to migrate or setup a database.
|
422
414
|
|
423
|
-
|
424
|
-
|
425
|
-
* Inspecting an object with an associated array of over 10 elements no longer
|
426
|
-
truncates the array, preventing `inspect` from looping infinitely in some
|
427
|
-
cases.
|
428
|
-
|
429
|
-
*Kevin McPhillips*
|
415
|
+
Runs `db:migrate` if the database exists or `db:setup` if it doesn't.
|
430
416
|
|
431
|
-
*
|
432
|
-
|
433
|
-
Fixes #25210.
|
417
|
+
*Roberto Miranda*
|
434
418
|
|
435
|
-
|
419
|
+
* Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
|
436
420
|
|
437
|
-
*
|
438
|
-
was provided as a Hash.
|
421
|
+
*DHH*
|
439
422
|
|
440
|
-
|
423
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
424
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
441
425
|
|
442
|
-
|
443
|
-
adapter returns `''` instead of `nil`.
|
426
|
+
Fixes #33249.
|
444
427
|
|
445
|
-
*
|
428
|
+
*Ryan H. Kerr*
|
446
429
|
|
447
|
-
*
|
430
|
+
* Add `ActiveRecord::Relation#extract_associated` for extracting associated records from a relation.
|
448
431
|
|
449
|
-
|
432
|
+
```
|
433
|
+
account.memberships.extract_associated(:user)
|
434
|
+
# => Returns collection of User records
|
435
|
+
```
|
450
436
|
|
451
|
-
|
452
|
-
t.string :name
|
453
|
-
t.index 'lower(name) varchar_pattern_ops'
|
454
|
-
end
|
437
|
+
*DHH*
|
455
438
|
|
456
|
-
|
439
|
+
* Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
|
457
440
|
|
458
|
-
|
441
|
+
For example:
|
459
442
|
|
460
|
-
|
443
|
+
```
|
444
|
+
Post.where(id: 123).annotate("this is a comment").to_sql
|
445
|
+
# SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
|
446
|
+
```
|
461
447
|
|
462
|
-
|
463
|
-
Requires mysql2 0.4.4+.
|
448
|
+
This can be useful in instrumentation or other analysis of issued queries.
|
464
449
|
|
465
|
-
*
|
450
|
+
*Matt Yoho*
|
466
451
|
|
467
|
-
*
|
468
|
-
instead of listed afterward as separate `add_index` lines.
|
452
|
+
* Support Optimizer Hints.
|
469
453
|
|
470
|
-
|
454
|
+
In most databases, a way to control the optimizer is by using optimizer hints,
|
455
|
+
which can be specified within individual statements.
|
471
456
|
|
472
|
-
|
473
|
-
`CREATE TABLE` query, no additional query per index.
|
457
|
+
Example (for MySQL):
|
474
458
|
|
475
|
-
|
459
|
+
Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
|
460
|
+
# SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
|
476
461
|
|
477
|
-
|
462
|
+
Example (for PostgreSQL with pg_hint_plan):
|
478
463
|
|
479
|
-
|
480
|
-
|
481
|
-
before checking uniqueness, we'd miss values that exceed the column limit.
|
464
|
+
Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
|
465
|
+
# SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
|
482
466
|
|
483
|
-
|
484
|
-
validation since the column limit guarantees no value that long exists.
|
485
|
-
When we insert the row, it'll raise `ActiveRecord::ValueTooLong` as we
|
486
|
-
expect.
|
467
|
+
See also:
|
487
468
|
|
488
|
-
|
489
|
-
|
490
|
-
|
469
|
+
* https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
|
470
|
+
* https://pghintplan.osdn.jp/pg_hint_plan.html
|
471
|
+
* https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
|
472
|
+
* https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
|
473
|
+
* https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
|
491
474
|
|
492
475
|
*Ryuta Kamizono*
|
493
476
|
|
494
|
-
*
|
495
|
-
Supported by MySQL and PostgreSQL adapters.
|
477
|
+
* Fix query attribute method on user-defined attribute to be aware of typecasted value.
|
496
478
|
|
497
|
-
|
479
|
+
For example, the following code no longer return false as casted non-empty string:
|
498
480
|
|
499
|
-
|
481
|
+
```
|
482
|
+
class Post < ActiveRecord::Base
|
483
|
+
attribute :user_defined_text, :text
|
484
|
+
end
|
500
485
|
|
501
|
-
|
486
|
+
Post.new(user_defined_text: "false").user_defined_text? # => true
|
487
|
+
```
|
502
488
|
|
503
|
-
*
|
489
|
+
*Yuji Kamijima*
|
504
490
|
|
505
|
-
|
506
|
-
According to the SQL standard, PRIMARY KEY should always imply NOT
|
507
|
-
NULL. Unfortunately, due to a bug in some early versions, this is not
|
508
|
-
the case in SQLite. Unless the column is an INTEGER PRIMARY KEY or the
|
509
|
-
table is a WITHOUT ROWID table or the column is declared NOT NULL,
|
510
|
-
SQLite allows NULL values in a PRIMARY KEY column. SQLite could be
|
511
|
-
fixed to conform to the standard, but doing so might break legacy
|
512
|
-
applications. Hence, it has been decided to merely document the fact
|
513
|
-
that SQLite allowing NULLs in most PRIMARY KEY columns.
|
491
|
+
* Quote empty ranges like other empty enumerables.
|
514
492
|
|
515
|
-
|
516
|
-
on implicit NOT NULL like MySQL and PostgreSQL adapters.
|
493
|
+
*Patrick Rebsch*
|
517
494
|
|
518
|
-
|
495
|
+
* Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`,
|
496
|
+
allowing bulk inserts akin to the bulk updates provided by `update_all` and
|
497
|
+
bulk deletes by `delete_all`.
|
519
498
|
|
520
|
-
|
499
|
+
Supports skipping or upserting duplicates through the `ON CONFLICT` syntax
|
500
|
+
for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
|
501
|
+
for MySQL.
|
521
502
|
|
522
|
-
|
503
|
+
*Bob Lail*
|
523
504
|
|
524
|
-
|
525
|
-
|
526
|
-
Created database 'blog_test'
|
505
|
+
* Add `rails db:seed:replant` that truncates tables of each database
|
506
|
+
for current environment and loads the seeds.
|
527
507
|
|
528
|
-
|
529
|
-
Dropped database 'blog_development'
|
530
|
-
Dropped database 'blog_test'
|
508
|
+
*bogdanvlviv*, *DHH*
|
531
509
|
|
532
|
-
|
533
|
-
`blog_development already exists` to `Database 'blog_development' already exists`.
|
534
|
-
and
|
535
|
-
`Couldn't drop blog_development` to `Couldn't drop database 'blog_development'`.
|
510
|
+
* Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter.
|
536
511
|
|
537
512
|
*bogdanvlviv*
|
538
513
|
|
539
|
-
*
|
540
|
-
with comments stored in database metadata. PostgreSQL & MySQL support.
|
541
|
-
|
542
|
-
create_table :pages, force: :cascade, comment: 'CMS content pages' do |t|
|
543
|
-
t.string :path, comment: 'Path fragment of page URL used for routing'
|
544
|
-
t.string :locale, comment: 'RFC 3066 locale code of website language section'
|
545
|
-
t.index [:path, :locale], comment: 'Look up pages by URI'
|
546
|
-
end
|
547
|
-
|
548
|
-
*Andrey Novikov*
|
514
|
+
* Deprecate mismatched collation comparison for uniqueness validator.
|
549
515
|
|
550
|
-
|
551
|
-
|
552
|
-
|
516
|
+
Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
|
517
|
+
To continue case sensitive comparison on the case insensitive column,
|
518
|
+
pass `case_sensitive: true` option explicitly to the uniqueness validator.
|
553
519
|
|
554
520
|
*Ryuta Kamizono*
|
555
521
|
|
556
|
-
*
|
557
|
-
|
558
|
-
Fixes #24234
|
559
|
-
|
560
|
-
*Sean Griffin*
|
522
|
+
* Add `reselect` method. This is a short-hand for `unscope(:select).select(fields)`.
|
561
523
|
|
562
|
-
|
524
|
+
Fixes #27340.
|
563
525
|
|
564
|
-
*
|
526
|
+
*Willian Gustavo Veiga*
|
565
527
|
|
566
|
-
*
|
528
|
+
* Add negative scopes for all enum values.
|
567
529
|
|
568
530
|
Example:
|
569
531
|
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
# When only one record is found on the table
|
574
|
-
Topic.one? # => true
|
575
|
-
|
576
|
-
*Kenta Shirai*
|
532
|
+
class Post < ActiveRecord::Base
|
533
|
+
enum status: %i[ drafted active trashed ]
|
534
|
+
end
|
577
535
|
|
578
|
-
|
579
|
-
|
536
|
+
Post.not_drafted # => where.not(status: :drafted)
|
537
|
+
Post.not_active # => where.not(status: :active)
|
538
|
+
Post.not_trashed # => where.not(status: :trashed)
|
580
539
|
|
581
|
-
|
540
|
+
*DHH*
|
582
541
|
|
583
|
-
|
542
|
+
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
584
543
|
|
585
|
-
|
544
|
+
Fixes #35214.
|
586
545
|
|
587
|
-
|
546
|
+
*Juani Villarejo*
|
588
547
|
|
589
|
-
*Chris Arcand*
|
590
548
|
|
591
|
-
|
592
|
-
Setting `strict: true` adds `STRICT_ALL_TABLES` to `sql_mode`. Setting
|
593
|
-
`strict: false` removes `STRICT_TRANS_TABLES`, `STRICT_ALL_TABLES`, and
|
594
|
-
`TRADITIONAL` from `sql_mode`.
|
549
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
595
550
|
|
596
|
-
|
551
|
+
* No changes.
|
597
552
|
|
598
|
-
* Execute default_scope defined by abstract class in the context of subclass.
|
599
553
|
|
600
|
-
|
601
|
-
Fixes #10658.
|
554
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
602
555
|
|
603
|
-
|
556
|
+
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
604
557
|
|
605
|
-
*
|
606
|
-
Previously every association with extension methods was transformed into an
|
607
|
-
instance dependent scope. This is no longer the case.
|
558
|
+
*Ryuta Kamizono*
|
608
559
|
|
609
|
-
|
560
|
+
* Ensure `update_all` series cares about optimistic locking.
|
610
561
|
|
611
|
-
*
|
562
|
+
*Ryuta Kamizono*
|
612
563
|
|
613
|
-
*
|
614
|
-
Use the `{insert|update|delete}` public methods instead.
|
564
|
+
* Don't allow `where` with non numeric string matches to 0 values.
|
615
565
|
|
616
566
|
*Ryuta Kamizono*
|
617
567
|
|
618
|
-
*
|
619
|
-
if the order or limit is ignored in a batch query, rather than logging a
|
620
|
-
warning message.
|
621
|
-
|
622
|
-
*Scott Ringwelski*
|
568
|
+
* Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`.
|
623
569
|
|
624
|
-
|
570
|
+
`destroy_by` allows relation to find all the records matching the condition and perform
|
571
|
+
`destroy_all` on the matched records.
|
625
572
|
|
626
573
|
Example:
|
627
574
|
|
628
|
-
|
629
|
-
|
630
|
-
class Article < ActiveRecord::Base
|
631
|
-
has_many :by_lines, -> { order(:position) }
|
632
|
-
has_many :authors, through: :by_lines
|
633
|
-
end
|
634
|
-
|
635
|
-
Fixes #17864.
|
636
|
-
|
637
|
-
*Yasyf Mohamedali*, *Joel Turkel*
|
638
|
-
|
639
|
-
* Ensure that the Suppressor runs before validations.
|
640
|
-
|
641
|
-
This moves the suppressor up to be run before validations rather than after
|
642
|
-
validations. There's no reason to validate a record you aren't planning on saving.
|
643
|
-
|
644
|
-
*Eileen M. Uchitelle*
|
645
|
-
|
646
|
-
* Save many-to-many objects based on association primary key.
|
647
|
-
|
648
|
-
Fixes #20995.
|
649
|
-
|
650
|
-
*himesh-r*
|
651
|
-
|
652
|
-
* Ensure that mutations of the array returned from `ActiveRecord::Relation#to_a`
|
653
|
-
do not affect the original relation, by returning a duplicate array each time.
|
654
|
-
|
655
|
-
This brings the behavior in line with `CollectionProxy#to_a`, which was
|
656
|
-
already more careful.
|
657
|
-
|
658
|
-
*Matthew Draper*
|
575
|
+
Person.destroy_by(name: 'David')
|
576
|
+
Person.destroy_by(name: 'David', rating: 4)
|
659
577
|
|
660
|
-
|
578
|
+
david = Person.find_by(name: 'David')
|
579
|
+
david.posts.destroy_by(id: [1, 2, 3])
|
661
580
|
|
662
|
-
|
581
|
+
`delete_by` allows relation to find all the records matching the condition and perform
|
582
|
+
`delete_all` on the matched records.
|
663
583
|
|
664
584
|
Example:
|
665
585
|
|
666
|
-
|
667
|
-
|
668
|
-
WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
|
669
|
-
OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
|
586
|
+
Person.delete_by(name: 'David')
|
587
|
+
Person.delete_by(name: 'David', rating: 4)
|
670
588
|
|
671
|
-
|
589
|
+
david = Person.find_by(name: 'David')
|
590
|
+
david.posts.delete_by(id: [1, 2, 3])
|
672
591
|
|
673
|
-
*
|
674
|
-
the same table definition would only create one foreign key.
|
592
|
+
*Abhay Nikam*
|
675
593
|
|
676
|
-
|
594
|
+
* Don't allow `where` with invalid value matches to nil values.
|
677
595
|
|
678
|
-
|
679
|
-
results in same child records getting added repeatedly to target.
|
596
|
+
Fixes #33624.
|
680
597
|
|
681
|
-
|
682
|
-
|
683
|
-
*Bogdan Gusiev*, *Jon Hinson*
|
684
|
-
|
685
|
-
* Rework `ActiveRecord::Relation#last`.
|
598
|
+
*Ryuta Kamizono*
|
686
599
|
|
687
|
-
|
688
|
-
2. Use SQL reverse order instead of loading relation if relation doesn't have limit
|
689
|
-
3. Deprecated relation loading when SQL order can not be automatically reversed
|
600
|
+
* SQLite3: Implement `add_foreign_key` and `remove_foreign_key`.
|
690
601
|
|
691
|
-
|
692
|
-
# before: SELECT ...
|
693
|
-
# after: No SQL
|
602
|
+
*Ryuta Kamizono*
|
694
603
|
|
695
|
-
|
696
|
-
|
697
|
-
# after: SELECT * FROM `topics` ORDER BY `topics`.`title` DESC LIMIT 1
|
604
|
+
* Deprecate using class level querying methods if the receiver scope
|
605
|
+
regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
|
698
606
|
|
699
|
-
|
700
|
-
# before: SELECT * FROM `topics`
|
701
|
-
# after: Deprecation Warning for irreversible order
|
607
|
+
*Ryuta Kamizono*
|
702
608
|
|
703
|
-
|
609
|
+
* Allow applications to automatically switch connections.
|
704
610
|
|
705
|
-
|
611
|
+
Adds a middleware and configuration options that can be used in your
|
612
|
+
application to automatically switch between the writing and reading
|
613
|
+
database connections.
|
706
614
|
|
707
|
-
|
615
|
+
`GET` and `HEAD` requests will read from the replica unless there was
|
616
|
+
a write in the last 2 seconds, otherwise they will read from the primary.
|
617
|
+
Non-get requests will always write to the primary. The middleware accepts
|
618
|
+
an argument for a Resolver class and an Operations class where you are able
|
619
|
+
to change how the auto-switcher works to be most beneficial for your
|
620
|
+
application.
|
708
621
|
|
709
|
-
|
622
|
+
To use the middleware in your application you can use the following
|
623
|
+
configuration options:
|
710
624
|
|
711
|
-
|
625
|
+
```
|
626
|
+
config.active_record.database_selector = { delay: 2.seconds }
|
627
|
+
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
628
|
+
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
629
|
+
```
|
712
630
|
|
713
|
-
|
631
|
+
To change the database selection strategy, pass a custom class to the
|
632
|
+
configuration options:
|
714
633
|
|
715
|
-
|
634
|
+
```
|
635
|
+
config.active_record.database_selector = { delay: 10.seconds }
|
636
|
+
config.active_record.database_resolver = MyResolver
|
637
|
+
config.active_record.database_resolver_context = MyResolver::MyCookies
|
638
|
+
```
|
716
639
|
|
717
|
-
|
640
|
+
*Eileen M. Uchitelle*
|
718
641
|
|
719
|
-
|
720
|
-
t.numeric :numeric_type, precision: 10, scale: 2
|
721
|
-
end
|
642
|
+
* MySQL: Support `:size` option to change text and blob size.
|
722
643
|
|
723
|
-
*
|
644
|
+
*Ryuta Kamizono*
|
724
645
|
|
725
|
-
*
|
726
|
-
Both PG 9.0 and 8.4 are past their end of life date:
|
727
|
-
http://www.postgresql.org/support/versioning/
|
646
|
+
* Make `t.timestamps` with precision by default.
|
728
647
|
|
729
|
-
*
|
648
|
+
*Ryuta Kamizono*
|
730
649
|
|
731
|
-
* `ActiveRecord::Relation#reverse_order` throws `ActiveRecord::IrreversibleOrderError`
|
732
|
-
when the order can not be reversed using current trivial algorithm.
|
733
|
-
Also raises the same error when `#reverse_order` is called on
|
734
|
-
relation without any order and table has no primary key:
|
735
650
|
|
736
|
-
|
737
|
-
# Before: SELECT `topics`.* FROM `topics` ORDER BY concat(author_name DESC, title) DESC
|
738
|
-
# After: raises ActiveRecord::IrreversibleOrderError
|
739
|
-
Edge.all.reverse_order
|
740
|
-
# Before: SELECT `edges`.* FROM `edges` ORDER BY `edges`.`` DESC
|
741
|
-
# After: raises ActiveRecord::IrreversibleOrderError
|
651
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
742
652
|
|
743
|
-
|
653
|
+
* Remove deprecated `#set_state` from the transaction object.
|
744
654
|
|
745
|
-
*
|
746
|
-
in one INSERT SQL.
|
655
|
+
*Rafael Mendonça França*
|
747
656
|
|
748
|
-
|
657
|
+
* Remove deprecated `#supports_statement_cache?` from the database adapters.
|
749
658
|
|
750
|
-
*
|
751
|
-
for the referenced column by default, without adding `index: true` option
|
752
|
-
to generated migration file. Users can opt out of this by passing
|
753
|
-
`index: false`.
|
659
|
+
*Rafael Mendonça França*
|
754
660
|
|
755
|
-
|
661
|
+
* Remove deprecated `#insert_fixtures` from the database adapters.
|
756
662
|
|
757
|
-
*
|
663
|
+
*Rafael Mendonça França*
|
758
664
|
|
759
|
-
*
|
760
|
-
instantiating the corresponding subclass. This makes it possible to define
|
761
|
-
custom STI mappings.
|
665
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
|
762
666
|
|
763
|
-
|
667
|
+
*Rafael Mendonça França*
|
764
668
|
|
765
|
-
|
669
|
+
* Do not allow passing the column name to `sum` when a block is passed.
|
766
670
|
|
767
|
-
*
|
768
|
-
they are passed as procs.
|
671
|
+
*Rafael Mendonça França*
|
769
672
|
|
770
|
-
|
771
|
-
the default option, instead of trying to quote it in incorrect fashion.
|
673
|
+
* Do not allow passing the column name to `count` when a block is passed.
|
772
674
|
|
773
|
-
|
675
|
+
*Rafael Mendonça França*
|
774
676
|
|
775
|
-
|
776
|
-
t.datetime :published_at, default: -> { 'NOW()' }
|
777
|
-
end
|
677
|
+
* Remove delegation of missing methods in a relation to arel.
|
778
678
|
|
779
|
-
*
|
679
|
+
*Rafael Mendonça França*
|
780
680
|
|
781
|
-
*
|
681
|
+
* Remove delegation of missing methods in a relation to private methods of the class.
|
782
682
|
|
783
|
-
|
683
|
+
*Rafael Mendonça França*
|
784
684
|
|
785
|
-
|
685
|
+
* Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
|
786
686
|
|
787
|
-
*
|
788
|
-
`schema_migrations` versions are guaranteed to be unique.
|
687
|
+
*Rafael Mendonça França*
|
789
688
|
|
790
|
-
|
791
|
-
not have a primary key.
|
689
|
+
* Change `SQLite3Adapter` to always represent boolean values as integers.
|
792
690
|
|
793
|
-
*
|
691
|
+
*Rafael Mendonça França*
|
794
692
|
|
795
|
-
*
|
693
|
+
* Remove ability to specify a timestamp name for `#cache_key`.
|
796
694
|
|
797
|
-
|
798
|
-
But in MySQL, these have limited length for each types (ref #21591, #21619).
|
799
|
-
This change adds short-hand methods for each text and blob types.
|
695
|
+
*Rafael Mendonça França*
|
800
696
|
|
801
|
-
|
697
|
+
* Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
|
802
698
|
|
803
|
-
|
804
|
-
t.tinyblob :tiny_blob
|
805
|
-
t.mediumblob :medium_blob
|
806
|
-
t.longblob :long_blob
|
807
|
-
t.tinytext :tiny_text
|
808
|
-
t.mediumtext :medium_text
|
809
|
-
t.longtext :long_text
|
810
|
-
end
|
699
|
+
*Rafael Mendonça França*
|
811
700
|
|
812
|
-
|
701
|
+
* Remove deprecated `expand_hash_conditions_for_aggregates`.
|
813
702
|
|
814
|
-
*
|
815
|
-
timestamp with offset specified to attribute of time type.
|
703
|
+
*Rafael Mendonça França*
|
816
704
|
|
817
|
-
|
705
|
+
* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
|
818
706
|
|
819
|
-
|
820
|
-
`loaded?` records if available.
|
707
|
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
|
821
708
|
|
822
|
-
*
|
709
|
+
*Laerti Papa*
|
823
710
|
|
824
|
-
*
|
825
|
-
`offset` method on relation instead.
|
711
|
+
* Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
|
826
712
|
|
827
|
-
*
|
713
|
+
*Gannon McGibbon*
|
828
714
|
|
829
|
-
*
|
715
|
+
* Add support for endless ranges introduces in Ruby 2.6.
|
830
716
|
|
831
|
-
|
717
|
+
*Greg Navis*
|
832
718
|
|
833
|
-
|
834
|
-
Message belongs_to :project, touch: true
|
835
|
-
Project belongs_to :account, touch: true
|
719
|
+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
|
836
720
|
|
837
|
-
|
838
|
-
call multiple times for the parent records.
|
721
|
+
*Ryuta Kamizono*
|
839
722
|
|
840
|
-
|
723
|
+
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
|
841
724
|
|
842
|
-
|
725
|
+
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
|
726
|
+
format for InnoDB tables. The default setting is `DYNAMIC`.
|
727
|
+
The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
|
843
728
|
|
844
|
-
*
|
845
|
-
has no explicit order defined.
|
729
|
+
*Ryuta Kamizono*
|
846
730
|
|
847
|
-
|
731
|
+
* Fix join table column quoting with SQLite.
|
848
732
|
|
849
|
-
*
|
733
|
+
*Gannon McGibbon*
|
850
734
|
|
851
|
-
*
|
852
|
-
change in the future, we can address that via Migration API Versioning.
|
735
|
+
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
853
736
|
|
854
|
-
*
|
737
|
+
*Alfred Dominic*
|
855
738
|
|
856
|
-
*
|
857
|
-
`ConnectionAdapters::SchemaStatements#indexes`. Previously the prefix would
|
858
|
-
be considered a full part of the index name, and only the schema in the
|
859
|
-
current search path would be considered.
|
739
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
860
740
|
|
861
|
-
*
|
741
|
+
*Ryuta Kamizono*
|
862
742
|
|
863
|
-
*
|
864
|
-
name to check for.
|
743
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
865
744
|
|
866
|
-
*
|
745
|
+
*Gannon McGibbon*
|
867
746
|
|
868
|
-
*
|
869
|
-
live on in a separate gem for now, but most users should just use `mysql2`.
|
747
|
+
* Add the ability to prevent writes to a database for the duration of a block.
|
870
748
|
|
871
|
-
|
749
|
+
Allows the application to prevent writes to a database. This can be useful when
|
750
|
+
you're building out multiple databases and want to make sure you're not sending
|
751
|
+
writes when you want a read.
|
872
752
|
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
model behavior.
|
753
|
+
If `while_preventing_writes` is called and the query is considered a write
|
754
|
+
query the database will raise an exception regardless of whether the database
|
755
|
+
user is able to write.
|
877
756
|
|
878
|
-
|
879
|
-
|
757
|
+
This is not meant to be a catch-all for write queries but rather a way to enforce
|
758
|
+
read-only queries without opening a second connection. One purpose of this is to
|
759
|
+
catch accidental writes, not all writes.
|
880
760
|
|
881
|
-
*
|
761
|
+
*Eileen M. Uchitelle*
|
882
762
|
|
883
|
-
*
|
884
|
-
defaults without breaking existing migrations, or forcing them to be
|
885
|
-
rewritten through a deprecation cycle.
|
763
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
886
764
|
|
887
|
-
|
765
|
+
*Gannon McGibbon*
|
888
766
|
|
889
|
-
|
890
|
-
def change
|
891
|
-
# ...
|
892
|
-
end
|
893
|
-
end
|
767
|
+
* Allow spaces in postgres table names.
|
894
768
|
|
895
|
-
|
769
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
|
896
770
|
|
897
|
-
*
|
898
|
-
fewer prepared statements for common tasks like pagination. To support this
|
899
|
-
change, passing a string containing a comma to `limit` has been deprecated,
|
900
|
-
and passing an Arel node to `limit` is no longer supported.
|
771
|
+
*Gannon McGibbon*
|
901
772
|
|
902
|
-
|
773
|
+
* Cached `columns_hash` fields should be excluded from `ResultSet#column_types`.
|
903
774
|
|
904
|
-
|
775
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
776
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
905
777
|
|
906
|
-
|
778
|
+
```ruby
|
779
|
+
class DeveloperName < ActiveRecord::Type::String
|
780
|
+
def deserialize(value)
|
781
|
+
"Developer: #{value}"
|
782
|
+
end
|
783
|
+
end
|
907
784
|
|
908
|
-
|
785
|
+
class AttributedDeveloper < ActiveRecord::Base
|
786
|
+
self.table_name = "developers"
|
909
787
|
|
910
|
-
|
911
|
-
after_commit :update_in_index_later, on: :update
|
912
|
-
after_commit :remove_from_index_later, on: :destroy
|
788
|
+
attribute :name, DeveloperName.new
|
913
789
|
|
914
|
-
|
790
|
+
self.ignored_columns += ["name"]
|
791
|
+
end
|
915
792
|
|
916
|
-
|
917
|
-
|
918
|
-
after_destroy_commit :remove_from_index_later
|
793
|
+
developer = AttributedDeveloper.create
|
794
|
+
developer.update_column :name, "name"
|
919
795
|
|
920
|
-
|
796
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
797
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
798
|
+
```
|
921
799
|
|
922
|
-
*
|
800
|
+
*Dmitry Tsepelev*
|
923
801
|
|
924
|
-
*
|
925
|
-
instantiating records through the base class.
|
802
|
+
* Make the implicit order column configurable.
|
926
803
|
|
927
|
-
|
804
|
+
When calling ordered finder methods such as `first` or `last` without an
|
805
|
+
explicit order clause, ActiveRecord sorts records by primary key. This can
|
806
|
+
result in unpredictable and surprising behaviour when the primary key is
|
807
|
+
not an auto-incrementing integer, for example when it's a UUID. This change
|
808
|
+
makes it possible to override the column used for implicit ordering such
|
809
|
+
that `first` and `last` will return more predictable results.
|
928
810
|
|
929
811
|
Example:
|
930
812
|
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
*Kuldeep Aggarwal*
|
936
|
-
|
937
|
-
* Fix `rake db:structure:dump` on Postgres when multiple schemas are used.
|
813
|
+
class Project < ActiveRecord::Base
|
814
|
+
self.implicit_order_column = "created_at"
|
815
|
+
end
|
938
816
|
|
939
|
-
|
817
|
+
*Tekin Suleyman*
|
940
818
|
|
941
|
-
|
819
|
+
* Bump minimum PostgreSQL version to 9.3.
|
942
820
|
|
943
|
-
*
|
821
|
+
*Yasuo Honda*
|
944
822
|
|
945
|
-
|
823
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
946
824
|
|
947
|
-
*
|
825
|
+
*Emmanuel Byrd*
|
948
826
|
|
949
|
-
|
827
|
+
* Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
|
950
828
|
|
951
|
-
|
829
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
|
952
830
|
|
953
|
-
|
954
|
-
Also deprecate passing arguments to `#tables`.
|
955
|
-
And deprecate `table_exists?`.
|
831
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
|
956
832
|
|
957
|
-
|
958
|
-
both tables and views while others (postgresql) just return tables. To make
|
959
|
-
their behavior consistent, `#tables` will return only tables in the future.
|
833
|
+
Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
|
960
834
|
|
961
|
-
|
962
|
-
their behavior consistent with `#tables`, `#table_exists?` will check only
|
963
|
-
tables in the future.
|
835
|
+
Example:
|
964
836
|
|
965
|
-
|
837
|
+
```
|
838
|
+
class MySubclassedError < ActiveRecord::StatementInvalid
|
839
|
+
def initialize(message, sql:, binds:)
|
840
|
+
super(message, sql: sql, binds: binds)
|
841
|
+
end
|
842
|
+
end
|
843
|
+
```
|
966
844
|
|
967
|
-
*
|
845
|
+
*Gannon McGibbon*
|
968
846
|
|
969
|
-
|
970
|
-
to it make easier to validate virtual associations built on top of Active Model
|
971
|
-
objects and/or serialized objects that implement a `valid?` instance method.
|
847
|
+
* Add an `:if_not_exists` option to `create_table`.
|
972
848
|
|
973
|
-
|
849
|
+
Example:
|
974
850
|
|
975
|
-
|
976
|
-
|
851
|
+
create_table :posts, if_not_exists: true do |t|
|
852
|
+
t.string :title
|
853
|
+
end
|
977
854
|
|
978
|
-
|
855
|
+
That would execute:
|
979
856
|
|
980
|
-
|
857
|
+
CREATE TABLE IF NOT EXISTS posts (
|
858
|
+
...
|
859
|
+
)
|
981
860
|
|
982
|
-
|
861
|
+
If the table already exists, `if_not_exists: false` (the default) raises an
|
862
|
+
exception whereas `if_not_exists: true` does nothing.
|
983
863
|
|
984
|
-
|
985
|
-
* 20150819202140_irreversible_migration.rb
|
986
|
-
* 20150823202140_add_admin_flag_to_users.rb
|
987
|
-
* 20150823202141_migration_tests.rb
|
988
|
-
* 2_we_need_reminders.rb
|
989
|
-
* 3_innocent_jointable.rb
|
864
|
+
*fatkodima*, *Stefan Kanev*
|
990
865
|
|
991
|
-
|
866
|
+
* Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
|
992
867
|
|
993
|
-
|
994
|
-
...
|
868
|
+
*Christophe Maximin*
|
995
869
|
|
996
|
-
|
997
|
-
--------------------------------------------------
|
998
|
-
up 001 ********** NO FILE **********
|
999
|
-
up 002 ********** NO FILE **********
|
1000
|
-
up 003 ********** NO FILE **********
|
1001
|
-
up 20150819202140 Irreversible migration
|
1002
|
-
up 20150823202140 Add admin flag to users
|
1003
|
-
up 20150823202141 Migration tests
|
870
|
+
* Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
|
1004
871
|
|
1005
|
-
|
872
|
+
*Gannon McGibbon*
|
1006
873
|
|
1007
|
-
|
1008
|
-
|
874
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
875
|
+
if the attribute does not exist.
|
1009
876
|
|
1010
|
-
|
1011
|
-
--------------------------------------------------
|
1012
|
-
up 001 Valid people have last names
|
1013
|
-
up 002 We need reminders
|
1014
|
-
up 003 Innocent jointable
|
1015
|
-
up 20150819202140 Irreversible migration
|
1016
|
-
up 20150823202140 Add admin flag to users
|
1017
|
-
up 20150823202141 Migration tests
|
877
|
+
*Sean Griffin*
|
1018
878
|
|
1019
|
-
|
879
|
+
* Add support for hash and URL configs in database hash of `ActiveRecord::Base.connected_to`.
|
1020
880
|
|
1021
|
-
|
1022
|
-
|
881
|
+
````
|
882
|
+
User.connected_to(database: { writing: "postgres://foo" }) do
|
883
|
+
User.create!(name: "Gannon")
|
884
|
+
end
|
1023
885
|
|
1024
|
-
|
886
|
+
config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
|
887
|
+
User.connected_to(database: { reading: config }) do
|
888
|
+
User.count
|
889
|
+
end
|
890
|
+
````
|
1025
891
|
|
1026
|
-
*
|
892
|
+
*Gannon McGibbon*
|
1027
893
|
|
1028
|
-
|
894
|
+
* Support default expression for MySQL.
|
1029
895
|
|
1030
|
-
|
896
|
+
MySQL 8.0.13 and higher supports default value to be a function or expression.
|
1031
897
|
|
1032
|
-
|
1033
|
-
Then the choice is the responsibility of the server and MySQL distribution.
|
898
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-table.html
|
1034
899
|
|
1035
900
|
*Ryuta Kamizono*
|
1036
901
|
|
1037
|
-
*
|
1038
|
-
`ActiveRecord::Relation#left_outer_joins`.
|
1039
|
-
|
1040
|
-
*Takashi Kokubun*
|
1041
|
-
|
1042
|
-
* Use advisory locking to raise a `ConcurrentMigrationError` instead of
|
1043
|
-
attempting to migrate when another migration is currently running.
|
1044
|
-
|
1045
|
-
*Sam Davies*
|
1046
|
-
|
1047
|
-
* Added `ActiveRecord::Relation#left_outer_joins`.
|
1048
|
-
|
1049
|
-
Example:
|
1050
|
-
|
1051
|
-
User.left_outer_joins(:posts)
|
1052
|
-
# => SELECT "users".* FROM "users" LEFT OUTER JOIN "posts" ON
|
1053
|
-
"posts"."user_id" = "users"."id"
|
1054
|
-
|
1055
|
-
*Florian Thomas*
|
1056
|
-
|
1057
|
-
* Support passing an array to `order` for SQL parameter sanitization.
|
1058
|
-
|
1059
|
-
*Aaron Suggs*
|
1060
|
-
|
1061
|
-
* Avoid disabling errors on the PostgreSQL connection when enabling the
|
1062
|
-
`standard_conforming_strings` setting. Errors were previously disabled because
|
1063
|
-
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
|
1064
|
-
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
|
1065
|
-
setting exists. Disabling errors caused problems when using a connection
|
1066
|
-
pooling tool like PgBouncer because it's not guaranteed to have the same
|
1067
|
-
connection between calls to `execute` and it could leave the connection
|
1068
|
-
with errors disabled.
|
1069
|
-
|
1070
|
-
Fixes #22101.
|
1071
|
-
|
1072
|
-
*Harry Marr*
|
1073
|
-
|
1074
|
-
* Set `scope.reordering_value` to `true` if `:reordering`-values are specified.
|
1075
|
-
|
1076
|
-
Fixes #21886.
|
1077
|
-
|
1078
|
-
*Hiroaki Izu*
|
1079
|
-
|
1080
|
-
* Add support for bidirectional destroy dependencies.
|
1081
|
-
|
1082
|
-
Fixes #13609.
|
1083
|
-
|
1084
|
-
Example:
|
1085
|
-
|
1086
|
-
class Content < ActiveRecord::Base
|
1087
|
-
has_one :position, dependent: :destroy
|
1088
|
-
end
|
902
|
+
* Support expression indexes for MySQL.
|
1089
903
|
|
1090
|
-
|
1091
|
-
|
1092
|
-
end
|
904
|
+
MySQL 8.0.13 and higher supports functional key parts that index
|
905
|
+
expression values rather than column or column prefix values.
|
1093
906
|
|
1094
|
-
|
907
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-index.html
|
1095
908
|
|
1096
|
-
*
|
1097
|
-
only instantiates one HABTM object because the join table hasn't a primary key.
|
909
|
+
*Ryuta Kamizono*
|
1098
910
|
|
1099
|
-
|
911
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
1100
912
|
|
1101
|
-
|
913
|
+
Fixes #33056.
|
1102
914
|
|
1103
|
-
|
915
|
+
*Federico Martinez*
|
1104
916
|
|
1105
|
-
|
1106
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
917
|
+
* Add basic API for connection switching to support multiple databases.
|
1107
918
|
|
1108
|
-
|
919
|
+
1) Adds a `connects_to` method for models to connect to multiple databases. Example:
|
1109
920
|
|
1110
|
-
|
1111
|
-
|
921
|
+
```
|
922
|
+
class AnimalsModel < ApplicationRecord
|
923
|
+
self.abstract_class = true
|
1112
924
|
|
1113
|
-
|
925
|
+
connects_to database: { writing: :animals_primary, reading: :animals_replica }
|
926
|
+
end
|
1114
927
|
|
1115
|
-
|
928
|
+
class Dog < AnimalsModel
|
929
|
+
# connected to both the animals_primary db for writing and the animals_replica for reading
|
930
|
+
end
|
931
|
+
```
|
1116
932
|
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
933
|
+
2) Adds a `connected_to` block method for switching connection roles or connecting to
|
934
|
+
a database that the model didn't connect to. Connecting to the database in this block is
|
935
|
+
useful when you have another defined connection, for example `slow_replica` that you don't
|
936
|
+
want to connect to by default but need in the console, or a specific code block.
|
1121
937
|
|
1122
|
-
|
938
|
+
```
|
939
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
940
|
+
Dog.first # finds dog from replica connected to AnimalsBase
|
941
|
+
Book.first # doesn't have a reading connection, will raise an error
|
942
|
+
end
|
943
|
+
```
|
1123
944
|
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
945
|
+
```
|
946
|
+
ActiveRecord::Base.connected_to(database: :slow_replica) do
|
947
|
+
SlowReplicaModel.first # if the db config has a slow_replica configuration this will be used to do the lookup, otherwise this will throw an exception
|
948
|
+
end
|
949
|
+
```
|
1128
950
|
|
1129
|
-
|
1130
|
-
belongs_to :guitar
|
1131
|
-
validates_numericality_of :pitch
|
1132
|
-
end
|
951
|
+
*Eileen M. Uchitelle*
|
1133
952
|
|
1134
|
-
|
1135
|
-
guitar.errors["tuning_pegs.pitch"] = ["is not a number"]
|
953
|
+
* Enum raises on invalid definition values
|
1136
954
|
|
1137
|
-
|
1138
|
-
|
955
|
+
When defining a Hash enum it can be easy to use `[]` instead of `{}`. This
|
956
|
+
commit checks that only valid definition values are provided, those can
|
957
|
+
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
958
|
+
raises an `ArgumentError`.
|
1139
959
|
|
1140
|
-
|
960
|
+
Fixes #33961
|
1141
961
|
|
1142
|
-
*
|
962
|
+
*Alberto Almagro*
|
1143
963
|
|
1144
|
-
|
964
|
+
* Reloading associations now clears the Query Cache like `Persistence#reload` does.
|
1145
965
|
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
966
|
+
```
|
967
|
+
class Post < ActiveRecord::Base
|
968
|
+
has_one :category
|
969
|
+
belongs_to :author
|
970
|
+
has_many :comments
|
971
|
+
end
|
972
|
+
|
973
|
+
# Each of the following will now clear the query cache.
|
974
|
+
post.reload_category
|
975
|
+
post.reload_author
|
976
|
+
post.comments.reload
|
977
|
+
```
|
1150
978
|
|
1151
|
-
*
|
979
|
+
*Christophe Maximin*
|
1152
980
|
|
1153
|
-
*
|
981
|
+
* Added `index` option for `change_table` migration helpers.
|
982
|
+
With this change you can create indexes while adding new
|
983
|
+
columns into the existing tables.
|
1154
984
|
|
1155
985
|
Example:
|
1156
986
|
|
1157
|
-
|
1158
|
-
|
987
|
+
change_table(:languages) do |t|
|
988
|
+
t.string :country_code, index: true
|
1159
989
|
end
|
1160
990
|
|
1161
|
-
*
|
991
|
+
*Mehmet Emin İNAÇ*
|
1162
992
|
|
1163
|
-
*
|
993
|
+
* Fix `transaction` reverting for migrations.
|
1164
994
|
|
1165
|
-
|
995
|
+
Before: Commands inside a `transaction` in a reverted migration ran uninverted.
|
996
|
+
Now: This change fixes that by reverting commands inside `transaction` block.
|
1166
997
|
|
1167
|
-
*
|
998
|
+
*fatkodima*, *David Verhasselt*
|
1168
999
|
|
1169
|
-
*
|
1000
|
+
* Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
|
1170
1001
|
|
1171
|
-
|
1172
|
-
has `JOIN` with another table which also has a column of the name.
|
1002
|
+
*Gannon McGibbon*, *Max Albrecht*
|
1173
1003
|
|
1174
|
-
|
1004
|
+
* Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
|
1175
1005
|
|
1176
|
-
*
|
1177
|
-
these queries will change often and are unlikely to have a cache hit.
|
1006
|
+
*Gannon McGibbon*
|
1178
1007
|
|
1179
|
-
|
1008
|
+
* Don't update counter cache unless the record is actually saved.
|
1180
1009
|
|
1181
|
-
|
1010
|
+
Fixes #31493, #33113, #33117.
|
1182
1011
|
|
1183
|
-
|
1012
|
+
*Ryuta Kamizono*
|
1184
1013
|
|
1185
|
-
|
1014
|
+
* Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
|
1186
1015
|
|
1187
|
-
*
|
1016
|
+
*Gannon McGibbon*, *Kevin Cheng*
|
1188
1017
|
|
1189
|
-
|
1018
|
+
* SQLite3 adapter supports expression indexes.
|
1190
1019
|
|
1191
|
-
|
1020
|
+
```
|
1021
|
+
create_table :users do |t|
|
1022
|
+
t.string :email
|
1023
|
+
end
|
1192
1024
|
|
1193
|
-
|
1194
|
-
|
1025
|
+
add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
|
1026
|
+
```
|
1195
1027
|
|
1196
|
-
*
|
1028
|
+
*Gray Kemmey*
|
1197
1029
|
|
1198
|
-
*
|
1199
|
-
passed an `ActiveRecord::Base` instance.
|
1030
|
+
* Allow subclasses to redefine autosave callbacks for associated records.
|
1200
1031
|
|
1201
|
-
Fixes #
|
1032
|
+
Fixes #33305.
|
1202
1033
|
|
1203
|
-
*
|
1034
|
+
*Andrey Subbota*
|
1204
1035
|
|
1205
|
-
*
|
1206
|
-
`add_reference`.
|
1036
|
+
* Bump minimum MySQL version to 5.5.8.
|
1207
1037
|
|
1208
|
-
|
1038
|
+
*Yasuo Honda*
|
1209
1039
|
|
1210
|
-
|
1040
|
+
* Use MySQL utf8mb4 character set by default.
|
1211
1041
|
|
1212
|
-
|
1042
|
+
`utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
|
1043
|
+
The previous default 3-Byte encoding character set `utf8` is not enough to support them.
|
1213
1044
|
|
1214
|
-
*
|
1045
|
+
*Yasuo Honda*
|
1215
1046
|
|
1216
|
-
*
|
1217
|
-
are all reflected in the database rather than overwriting each other.
|
1047
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
1218
1048
|
|
1219
|
-
*
|
1049
|
+
*Darwin Wu*
|
1220
1050
|
|
1221
|
-
*
|
1051
|
+
* Configuration item `config.filter_parameters` could also filter out
|
1052
|
+
sensitive values of database columns when calling `#inspect`.
|
1053
|
+
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
1054
|
+
specify sensitive attributes to specific model.
|
1222
1055
|
|
1223
|
-
|
1056
|
+
```
|
1057
|
+
Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
|
1058
|
+
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
|
1059
|
+
SecureAccount.filter_attributes += [:name]
|
1060
|
+
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
|
1061
|
+
```
|
1224
1062
|
|
1225
|
-
*
|
1063
|
+
*Zhang Kang*, *Yoshiyuki Kinjo*
|
1226
1064
|
|
1227
|
-
*
|
1065
|
+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
|
1066
|
+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
1067
|
+
and `joins_per_query` methods in `DatabaseLimits`.
|
1228
1068
|
|
1229
1069
|
*Ryuta Kamizono*
|
1230
1070
|
|
1231
|
-
*
|
1232
|
-
|
1233
|
-
To load the fixtures file `accounts.yml` as the `User` model, use:
|
1234
|
-
|
1235
|
-
_fixture:
|
1236
|
-
model_class: User
|
1237
|
-
david:
|
1238
|
-
name: David
|
1239
|
-
|
1240
|
-
Fixes #9516.
|
1241
|
-
|
1242
|
-
*Roque Pinel*
|
1243
|
-
|
1244
|
-
* Don't require a database connection to load a class which uses acceptance
|
1245
|
-
validations.
|
1246
|
-
|
1247
|
-
*Sean Griffin*
|
1248
|
-
|
1249
|
-
* Correctly apply `unscope` when preloading through associations.
|
1071
|
+
* `ActiveRecord::Base.configurations` now returns an object.
|
1250
1072
|
|
1251
|
-
|
1073
|
+
`ActiveRecord::Base.configurations` used to return a hash, but this
|
1074
|
+
is an inflexible data model. In order to improve multiple-database
|
1075
|
+
handling in Rails, we've changed this to return an object. Some methods
|
1076
|
+
are provided to make the object behave hash-like in order to ease the
|
1077
|
+
transition process. Since most applications don't manipulate the hash
|
1078
|
+
we've decided to add backwards-compatible functionality that will throw
|
1079
|
+
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
1080
|
+
will use the new version internally and externally.
|
1252
1081
|
|
1253
|
-
|
1082
|
+
For example, the following `database.yml`:
|
1254
1083
|
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
m = Model.create!
|
1261
|
-
m.created_at.usec == m.reload.created_at.usec # => false
|
1262
|
-
# due to different precision in Time.now and database column
|
1084
|
+
```
|
1085
|
+
development:
|
1086
|
+
adapter: sqlite3
|
1087
|
+
database: db/development.sqlite3
|
1088
|
+
```
|
1263
1089
|
|
1264
|
-
|
1265
|
-
enough by default) the value changes when model is reloaded from the
|
1266
|
-
database. This patch fixes that issue ensuring that any timestamp
|
1267
|
-
assigned as an attribute is converted to column precision under the
|
1268
|
-
attribute.
|
1090
|
+
Used to become a hash:
|
1269
1091
|
|
1270
|
-
|
1092
|
+
```
|
1093
|
+
{ "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
|
1094
|
+
```
|
1271
1095
|
|
1272
|
-
|
1273
|
-
These methods determine what relations can be used to back Active Record
|
1274
|
-
models (usually tables and views).
|
1096
|
+
Is now converted into the following object:
|
1275
1097
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1098
|
+
```
|
1099
|
+
#<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
|
1100
|
+
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
|
1101
|
+
@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
|
1102
|
+
]
|
1103
|
+
```
|
1279
1104
|
|
1280
|
-
|
1105
|
+
Iterating over the database configurations has also changed. Instead of
|
1106
|
+
calling hash methods on the `configurations` hash directly, a new method `configs_for` has
|
1107
|
+
been provided that allows you to select the correct configuration. `env_name` and
|
1108
|
+
`spec_name` arguments are optional. For example, these return an array of
|
1109
|
+
database config objects for the requested environment and a single database config object
|
1110
|
+
will be returned for the requested environment and specification name respectively.
|
1281
1111
|
|
1282
|
-
|
1283
|
-
|
1112
|
+
```
|
1113
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development")
|
1114
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
1115
|
+
```
|
1284
1116
|
|
1285
|
-
*
|
1117
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1286
1118
|
|
1287
|
-
*
|
1288
|
-
mysql commands (like `mysqldump`) is not successful.
|
1119
|
+
* Add database configuration to disable advisory locks.
|
1289
1120
|
|
1290
|
-
|
1121
|
+
```
|
1122
|
+
production:
|
1123
|
+
adapter: postgresql
|
1124
|
+
advisory_locks: false
|
1125
|
+
```
|
1291
1126
|
|
1292
|
-
*
|
1127
|
+
*Guo Xiang*
|
1293
1128
|
|
1294
|
-
|
1129
|
+
* SQLite3 adapter `alter_table` method restores foreign keys.
|
1295
1130
|
|
1296
|
-
*
|
1131
|
+
*Yasuo Honda*
|
1297
1132
|
|
1298
|
-
*
|
1133
|
+
* Allow `:to_table` option to `invert_remove_foreign_key`.
|
1299
1134
|
|
1300
1135
|
Example:
|
1301
1136
|
|
1302
|
-
|
1303
|
-
t.unsigned_integer :quantity
|
1304
|
-
t.unsigned_bigint :total
|
1305
|
-
t.unsigned_float :percentage
|
1306
|
-
t.unsigned_decimal :price, precision: 10, scale: 2
|
1307
|
-
end
|
1308
|
-
|
1309
|
-
The `unsigned: true` option may be used for the primary key:
|
1310
|
-
|
1311
|
-
create_table :foos, id: :bigint, unsigned: true do |t|
|
1312
|
-
…
|
1313
|
-
end
|
1137
|
+
remove_foreign_key :accounts, to_table: :owners
|
1314
1138
|
|
1315
|
-
*
|
1139
|
+
*Nikolay Epifanov*, *Rich Chen*
|
1316
1140
|
|
1317
|
-
* Add
|
1141
|
+
* Add environment & load_config dependency to `bin/rake db:seed` to enable
|
1142
|
+
seed load in environments without Rails and custom DB configuration
|
1318
1143
|
|
1319
|
-
*
|
1144
|
+
*Tobias Bielohlawek*
|
1320
1145
|
|
1321
|
-
*
|
1146
|
+
* Fix default value for mysql time types with specified precision.
|
1322
1147
|
|
1323
|
-
|
1148
|
+
*Nikolay Kondratyev*
|
1324
1149
|
|
1325
|
-
|
1326
|
-
t.string :region
|
1327
|
-
t.integer :code
|
1328
|
-
end
|
1150
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
1329
1151
|
|
1330
1152
|
*Ryuta Kamizono*
|
1331
1153
|
|
1332
|
-
*
|
1333
|
-
model class that defines the association.
|
1154
|
+
* Migrations raise when duplicate column definition.
|
1334
1155
|
|
1335
|
-
|
1156
|
+
Fixes #33024.
|
1336
1157
|
|
1337
|
-
*
|
1158
|
+
*Federico Martinez*
|
1338
1159
|
|
1339
|
-
|
1160
|
+
* Bump minimum SQLite version to 3.8
|
1340
1161
|
|
1341
|
-
*
|
1342
|
-
`ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
|
1343
|
-
`Migrator.migrations_paths`.
|
1162
|
+
*Yasuo Honda*
|
1344
1163
|
|
1345
|
-
|
1164
|
+
* Fix parent record should not get saved with duplicate children records.
|
1346
1165
|
|
1347
|
-
|
1166
|
+
Fixes #32940.
|
1348
1167
|
|
1349
|
-
|
1350
|
-
details.
|
1168
|
+
*Santosh Wadghule*
|
1351
1169
|
|
1352
|
-
|
1170
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
1353
1171
|
|
1354
|
-
*
|
1355
|
-
and `ActiveRecord::Relation#destroy_all`.
|
1172
|
+
*Brian Durand*
|
1356
1173
|
|
1357
|
-
|
1174
|
+
* Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
|
1175
|
+
use loaded association ids if present.
|
1358
1176
|
|
1359
|
-
*
|
1360
|
-
an `ActiveModel::ForbiddenAttributesError` if the parameters include a
|
1361
|
-
`type` field that has not been explicitly permitted. Previously, the
|
1362
|
-
`type` field was simply ignored in the same situation.
|
1177
|
+
*Graham Turner*
|
1363
1178
|
|
1364
|
-
|
1179
|
+
* Add support to preload associations of polymorphic associations when not all the records have the requested associations.
|
1365
1180
|
|
1366
|
-
*
|
1367
|
-
schema names.
|
1181
|
+
*Dana Sherson*
|
1368
1182
|
|
1369
|
-
|
1183
|
+
* Add `touch_all` method to `ActiveRecord::Relation`.
|
1370
1184
|
|
1371
1185
|
Example:
|
1372
1186
|
|
1373
|
-
|
1374
|
-
# CREATE SCHEMA "my.schema";
|
1375
|
-
|
1376
|
-
*Yves Senn*
|
1187
|
+
Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
1377
1188
|
|
1378
|
-
*
|
1379
|
-
possible to drop a schema that might exist without raising an exception if
|
1380
|
-
it doesn't.
|
1189
|
+
*fatkodima*, *duggiefresh*
|
1381
1190
|
|
1382
|
-
|
1383
|
-
|
1384
|
-
* Only try to nullify has_one target association if the record is persisted.
|
1385
|
-
|
1386
|
-
Fixes #21223.
|
1387
|
-
|
1388
|
-
*Agis Anastasopoulos*
|
1389
|
-
|
1390
|
-
* Uniqueness validator raises descriptive error when running on a persisted
|
1391
|
-
record without primary key.
|
1392
|
-
|
1393
|
-
Fixes #21304.
|
1394
|
-
|
1395
|
-
*Yves Senn*
|
1396
|
-
|
1397
|
-
* Add a native JSON data type support in MySQL.
|
1398
|
-
|
1399
|
-
Example:
|
1400
|
-
|
1401
|
-
create_table :json_data_type do |t|
|
1402
|
-
t.json :settings
|
1403
|
-
end
|
1404
|
-
|
1405
|
-
*Ryuta Kamizono*
|
1406
|
-
|
1407
|
-
* Descriptive error message when fixtures contain a missing column.
|
1408
|
-
|
1409
|
-
Fixes #21201.
|
1410
|
-
|
1411
|
-
*Yves Senn*
|
1412
|
-
|
1413
|
-
* `ActiveRecord::Tasks::PostgreSQLDatabaseTasks` fail if shellout to
|
1414
|
-
postgresql commands (like `pg_dump`) is not successful.
|
1415
|
-
|
1416
|
-
*Bryan Paxton*, *Nate Berkopec*
|
1417
|
-
|
1418
|
-
* Add `ActiveRecord::Relation#in_batches` to work with records and relations
|
1419
|
-
in batches.
|
1420
|
-
|
1421
|
-
Available options are `of` (batch size), `load`, `start`, and `finish`.
|
1422
|
-
|
1423
|
-
Examples:
|
1424
|
-
|
1425
|
-
Person.in_batches.each_record(&:party_all_night!)
|
1426
|
-
Person.in_batches.update_all(awesome: true)
|
1427
|
-
Person.in_batches.delete_all
|
1428
|
-
Person.in_batches.each do |relation|
|
1429
|
-
relation.delete_all
|
1430
|
-
sleep 10 # Throttles the delete queries
|
1431
|
-
end
|
1432
|
-
|
1433
|
-
Fixes #20933.
|
1434
|
-
|
1435
|
-
*Sina Siadat*
|
1436
|
-
|
1437
|
-
* Added methods for PostgreSQL geometric data types to use in migrations.
|
1438
|
-
|
1439
|
-
Example:
|
1440
|
-
|
1441
|
-
create_table :foo do |t|
|
1442
|
-
t.line :foo_line
|
1443
|
-
t.lseg :foo_lseg
|
1444
|
-
t.box :foo_box
|
1445
|
-
t.path :foo_path
|
1446
|
-
t.polygon :foo_polygon
|
1447
|
-
t.circle :foo_circle
|
1448
|
-
end
|
1449
|
-
|
1450
|
-
*Mehmet Emin İNAÇ*
|
1451
|
-
|
1452
|
-
* Add `cache_key` to `ActiveRecord::Relation`.
|
1453
|
-
|
1454
|
-
Example:
|
1455
|
-
|
1456
|
-
@users = User.where("name like ?", "%Alberto%")
|
1457
|
-
@users.cache_key
|
1458
|
-
# => "/users/query-5942b155a43b139f2471b872ac54251f-3-20150714212107656125000"
|
1459
|
-
|
1460
|
-
*Alberto Fernández-Capel*
|
1461
|
-
|
1462
|
-
* Properly allow uniqueness validations on primary keys.
|
1463
|
-
|
1464
|
-
Fixes #20966.
|
1465
|
-
|
1466
|
-
*Sean Griffin*, *presskey*
|
1467
|
-
|
1468
|
-
* Don't raise an error if an association failed to destroy when `destroy` was
|
1469
|
-
called on the parent (as opposed to `destroy!`).
|
1470
|
-
|
1471
|
-
Fixes #20991.
|
1472
|
-
|
1473
|
-
*Sean Griffin*
|
1474
|
-
|
1475
|
-
* `ActiveRecord::RecordNotFound` modified to store model name, primary_key and
|
1476
|
-
id of the caller model. It allows the catcher of this exception to make
|
1477
|
-
a better decision to what to do with it.
|
1478
|
-
|
1479
|
-
Example:
|
1480
|
-
|
1481
|
-
class SomeAbstractController < ActionController::Base
|
1482
|
-
rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404
|
1483
|
-
|
1484
|
-
private def redirect_to_404(e)
|
1485
|
-
return redirect_to(posts_url) if e.model == 'Post'
|
1486
|
-
raise
|
1487
|
-
end
|
1488
|
-
end
|
1489
|
-
|
1490
|
-
*Sameer Rahmani*
|
1491
|
-
|
1492
|
-
* Deprecate the keys for association `restrict_dependent_destroy` errors in favor
|
1493
|
-
of new key names.
|
1494
|
-
|
1495
|
-
Previously `has_one` and `has_many` associations were using the
|
1496
|
-
`one` and `many` keys respectively. Both of these keys have special
|
1497
|
-
meaning in I18n (they are considered to be pluralizations) so by
|
1498
|
-
renaming them to `has_one` and `has_many` we make the messages more explicit
|
1499
|
-
and most importantly they don't clash with linguistical systems that need to
|
1500
|
-
validate translation keys (and their pluralizations).
|
1501
|
-
|
1502
|
-
The `:'restrict_dependent_destroy.one'` key should be replaced with
|
1503
|
-
`:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'`
|
1504
|
-
with `:'restrict_dependent_destroy.has_many'`.
|
1505
|
-
|
1506
|
-
*Roque Pinel*, *Christopher Dell*
|
1507
|
-
|
1508
|
-
* Fix state being carried over from previous transaction.
|
1509
|
-
|
1510
|
-
Considering the following example where `name` is a required attribute.
|
1511
|
-
Before we had `new_record?` returning `true` for a persisted record:
|
1512
|
-
|
1513
|
-
author = Author.create! name: 'foo'
|
1514
|
-
author.name = nil
|
1515
|
-
author.save # => false
|
1516
|
-
author.new_record? # => true
|
1517
|
-
|
1518
|
-
Fixes #20824.
|
1519
|
-
|
1520
|
-
*Roque Pinel*
|
1521
|
-
|
1522
|
-
* Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
|
1523
|
-
when validating associations.
|
1524
|
-
|
1525
|
-
Fixes #20882.
|
1526
|
-
|
1527
|
-
*Sean Griffin*
|
1528
|
-
|
1529
|
-
* Fix a bug where counter_cache doesn't always work with polymorphic
|
1530
|
-
relations.
|
1531
|
-
|
1532
|
-
Fixes #16407.
|
1533
|
-
|
1534
|
-
*Stefan Kanev*, *Sean Griffin*
|
1535
|
-
|
1536
|
-
* Ensure that cyclic associations with autosave don't cause duplicate errors
|
1537
|
-
to be added to the parent record.
|
1538
|
-
|
1539
|
-
Fixes #20874.
|
1540
|
-
|
1541
|
-
*Sean Griffin*
|
1542
|
-
|
1543
|
-
* Ensure that `ActionController::Parameters` can still be passed to nested
|
1544
|
-
attributes.
|
1545
|
-
|
1546
|
-
Fixes #20922.
|
1547
|
-
|
1548
|
-
*Sean Griffin*
|
1549
|
-
|
1550
|
-
* Deprecate force association reload by passing a truthy argument to
|
1551
|
-
association method.
|
1552
|
-
|
1553
|
-
For collection association, you can call `#reload` on association proxy to
|
1554
|
-
force a reload:
|
1555
|
-
|
1556
|
-
@user.posts.reload # Instead of @user.posts(true)
|
1557
|
-
|
1558
|
-
For singular association, you can call `#reload` on the parent object to
|
1559
|
-
clear its association cache then call the association method:
|
1560
|
-
|
1561
|
-
@user.reload.profile # Instead of @user.profile(true)
|
1562
|
-
|
1563
|
-
Passing a truthy argument to force association to reload will be removed in
|
1564
|
-
Rails 5.1.
|
1565
|
-
|
1566
|
-
*Prem Sichanugrist*
|
1567
|
-
|
1568
|
-
* Replaced `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`
|
1569
|
-
from the concurrent-ruby gem.
|
1570
|
-
|
1571
|
-
*Jerry D'Antonio*
|
1572
|
-
|
1573
|
-
* Fix through associations using scopes having the scope merged multiple
|
1574
|
-
times.
|
1575
|
-
|
1576
|
-
Fixes #20721.
|
1577
|
-
Fixes #20727.
|
1578
|
-
|
1579
|
-
*Sean Griffin*
|
1580
|
-
|
1581
|
-
* `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
|
1582
|
-
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
1583
|
-
|
1584
|
-
Fixes #20743.
|
1585
|
-
|
1586
|
-
*Yves Senn*
|
1587
|
-
|
1588
|
-
* Add alternate syntax to make `change_column_default` reversible.
|
1589
|
-
|
1590
|
-
User can pass in `:from` and `:to` to make `change_column_default` command
|
1591
|
-
become reversible.
|
1592
|
-
|
1593
|
-
Example:
|
1594
|
-
|
1595
|
-
change_column_default :posts, :status, from: nil, to: "draft"
|
1596
|
-
change_column_default :users, :authorized, from: true, to: false
|
1597
|
-
|
1598
|
-
*Prem Sichanugrist*
|
1599
|
-
|
1600
|
-
* Prevent error when using `force_reload: true` on an unassigned polymorphic
|
1601
|
-
belongs_to association.
|
1602
|
-
|
1603
|
-
Fixes #20426.
|
1604
|
-
|
1605
|
-
*James Dabbs*
|
1606
|
-
|
1607
|
-
* Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
|
1608
|
-
a wrong type to a namespaced association.
|
1609
|
-
|
1610
|
-
Fixes #20545.
|
1611
|
-
|
1612
|
-
*Diego Carrion*
|
1613
|
-
|
1614
|
-
* `validates_absence_of` respects `marked_for_destruction?`.
|
1615
|
-
|
1616
|
-
Fixes #20449.
|
1617
|
-
|
1618
|
-
*Yves Senn*
|
1619
|
-
|
1620
|
-
* Include the `Enumerable` module in `ActiveRecord::Relation`
|
1621
|
-
|
1622
|
-
*Sean Griffin*, *bogdan*
|
1623
|
-
|
1624
|
-
* Use `Enumerable#sum` in `ActiveRecord::Relation` if a block is given.
|
1625
|
-
|
1626
|
-
*Sean Griffin*
|
1627
|
-
|
1628
|
-
* Let `WITH` queries (Common Table Expressions) be explainable.
|
1629
|
-
|
1630
|
-
*Vladimir Kochnev*
|
1631
|
-
|
1632
|
-
* Make `remove_index :table, :column` reversible.
|
1633
|
-
|
1634
|
-
*Yves Senn*
|
1635
|
-
|
1636
|
-
* Fixed an error which would occur in dirty checking when calling
|
1637
|
-
`update_attributes` from a getter.
|
1638
|
-
|
1639
|
-
Fixes #20531.
|
1640
|
-
|
1641
|
-
*Sean Griffin*
|
1642
|
-
|
1643
|
-
* Make `remove_foreign_key` reversible. Any foreign key options must be
|
1644
|
-
specified, similar to `remove_column`.
|
1645
|
-
|
1646
|
-
*Aster Ryan*
|
1647
|
-
|
1648
|
-
* Add `:_prefix` and `:_suffix` options to `enum` definition.
|
1649
|
-
|
1650
|
-
Fixes #17511, #17415.
|
1651
|
-
|
1652
|
-
*Igor Kapkov*
|
1653
|
-
|
1654
|
-
* Correctly handle decimal arrays with defaults in the schema dumper.
|
1655
|
-
|
1656
|
-
Fixes #20515.
|
1657
|
-
|
1658
|
-
*Sean Griffin*, *jmondo*
|
1659
|
-
|
1660
|
-
* Deprecate the PostgreSQL `:point` type in favor of a new one which will return
|
1661
|
-
`Point` objects instead of an `Array`
|
1662
|
-
|
1663
|
-
*Sean Griffin*
|
1664
|
-
|
1665
|
-
* Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
|
1666
|
-
as columns.
|
1667
|
-
|
1668
|
-
Fixes #20360.
|
1669
|
-
|
1670
|
-
*Sean Griffin*
|
1671
|
-
|
1672
|
-
* Do not set `sql_mode` if `strict: :default` is specified.
|
1673
|
-
|
1674
|
-
# config/database.yml
|
1675
|
-
production:
|
1676
|
-
adapter: mysql2
|
1677
|
-
database: foo_prod
|
1678
|
-
user: foo
|
1679
|
-
strict: :default
|
1680
|
-
|
1681
|
-
*Ryuta Kamizono*
|
1682
|
-
|
1683
|
-
* Allow proc defaults to be passed to the attributes API. See documentation
|
1684
|
-
for examples.
|
1685
|
-
|
1686
|
-
*Sean Griffin*, *Kir Shatrov*
|
1687
|
-
|
1688
|
-
* SQLite: `:collation` support for string and text columns.
|
1689
|
-
|
1690
|
-
Example:
|
1691
|
-
|
1692
|
-
create_table :foo do |t|
|
1693
|
-
t.string :string_nocase, collation: 'NOCASE'
|
1694
|
-
t.text :text_rtrim, collation: 'RTRIM'
|
1695
|
-
end
|
1696
|
-
|
1697
|
-
add_column :foo, :title, :string, collation: 'RTRIM'
|
1698
|
-
|
1699
|
-
change_column :foo, :title, :string, collation: 'NOCASE'
|
1700
|
-
|
1701
|
-
*Akshay Vishnoi*
|
1702
|
-
|
1703
|
-
* Allow the use of symbols or strings to specify enum values in test
|
1704
|
-
fixtures:
|
1705
|
-
|
1706
|
-
awdr:
|
1707
|
-
title: "Agile Web Development with Rails"
|
1708
|
-
status: :proposed
|
1709
|
-
|
1710
|
-
*George Claghorn*
|
1711
|
-
|
1712
|
-
* Clear query cache when `ActiveRecord::Base#reload` is called.
|
1713
|
-
|
1714
|
-
*Shane Hender, Pierre Nespo*
|
1715
|
-
|
1716
|
-
* Include stored procedures and function on the MySQL structure dump.
|
1717
|
-
|
1718
|
-
*Jonathan Worek*
|
1719
|
-
|
1720
|
-
* Pass `:extend` option for `has_and_belongs_to_many` associations to the
|
1721
|
-
underlying `has_many :through`.
|
1722
|
-
|
1723
|
-
*Jaehyun Shin*
|
1724
|
-
|
1725
|
-
* Deprecate `Relation#uniq` use `Relation#distinct` instead.
|
1726
|
-
|
1727
|
-
See #9683.
|
1728
|
-
|
1729
|
-
*Yves Senn*
|
1730
|
-
|
1731
|
-
* Allow single table inheritance instantiation to work when storing
|
1732
|
-
demodulized class names.
|
1733
|
-
|
1734
|
-
*Alex Robbin*
|
1735
|
-
|
1736
|
-
* Correctly pass MySQL options when using `structure_dump` or
|
1737
|
-
`structure_load`.
|
1738
|
-
|
1739
|
-
Specifically, it fixes an issue when using SSL authentication.
|
1740
|
-
|
1741
|
-
*Alex Coomans*
|
1742
|
-
|
1743
|
-
* Correctly dump `:options` on `create_table` for MySQL.
|
1744
|
-
|
1745
|
-
*Ryuta Kamizono*
|
1746
|
-
|
1747
|
-
* PostgreSQL: `:collation` support for string and text columns.
|
1748
|
-
|
1749
|
-
Example:
|
1750
|
-
|
1751
|
-
create_table :foos do |t|
|
1752
|
-
t.string :string_en, collation: 'en_US.UTF-8'
|
1753
|
-
t.text :text_ja, collation: 'ja_JP.UTF-8'
|
1754
|
-
end
|
1755
|
-
|
1756
|
-
*Ryuta Kamizono*
|
1757
|
-
|
1758
|
-
* Remove `ActiveRecord::Serialization::XmlSerializer` from core.
|
1759
|
-
|
1760
|
-
*Zachary Scott*
|
1761
|
-
|
1762
|
-
* Make `unscope` aware of "less than" and "greater than" conditions.
|
1763
|
-
|
1764
|
-
*TAKAHASHI Kazuaki*
|
1765
|
-
|
1766
|
-
* `find_by` and `find_by!` raise `ArgumentError` when called without
|
1767
|
-
arguments.
|
1768
|
-
|
1769
|
-
*Kohei Suzuki*
|
1770
|
-
|
1771
|
-
* Revert behavior of `db:schema:load` back to loading the full
|
1772
|
-
environment. This ensures that initializers are run.
|
1773
|
-
|
1774
|
-
Fixes #19545.
|
1775
|
-
|
1776
|
-
*Yves Senn*
|
1777
|
-
|
1778
|
-
* Fix missing index when using `timestamps` with the `index` option.
|
1779
|
-
|
1780
|
-
The `index` option used with `timestamps` should be passed to both
|
1781
|
-
`column` definitions for `created_at` and `updated_at` rather than just
|
1782
|
-
the first.
|
1783
|
-
|
1784
|
-
*Paul Mucur*
|
1785
|
-
|
1786
|
-
* Rename `:class` to `:anonymous_class` in association options.
|
1787
|
-
|
1788
|
-
Fixes #19659.
|
1789
|
-
|
1790
|
-
*Andrew White*
|
1791
|
-
|
1792
|
-
* Autosave existing records on a has many through association when the parent
|
1793
|
-
is new.
|
1794
|
-
|
1795
|
-
Fixes #19782.
|
1796
|
-
|
1797
|
-
*Sean Griffin*
|
1798
|
-
|
1799
|
-
* Fixed a bug where uniqueness validations would error on out of range values,
|
1800
|
-
even if an validation should have prevented it from hitting the database.
|
1801
|
-
|
1802
|
-
*Andrey Voronkov*
|
1803
|
-
|
1804
|
-
* MySQL: `:charset` and `:collation` support for string and text columns.
|
1805
|
-
|
1806
|
-
Example:
|
1807
|
-
|
1808
|
-
create_table :foos do |t|
|
1809
|
-
t.string :string_utf8_bin, charset: 'utf8', collation: 'utf8_bin'
|
1810
|
-
t.text :text_ascii, charset: 'ascii'
|
1811
|
-
end
|
1812
|
-
|
1813
|
-
*Ryuta Kamizono*
|
1814
|
-
|
1815
|
-
* Foreign key related methods in the migration DSL respect
|
1816
|
-
`ActiveRecord::Base.pluralize_table_names = false`.
|
1817
|
-
|
1818
|
-
Fixes #19643.
|
1819
|
-
|
1820
|
-
*Mehmet Emin İNAÇ*
|
1821
|
-
|
1822
|
-
* Reduce memory usage from loading types on PostgreSQL.
|
1823
|
-
|
1824
|
-
Fixes #19578.
|
1825
|
-
|
1826
|
-
*Sean Griffin*
|
1827
|
-
|
1828
|
-
* Add `config.active_record.warn_on_records_fetched_greater_than` option.
|
1829
|
-
|
1830
|
-
When set to an integer, a warning will be logged whenever a result set
|
1831
|
-
larger than the specified size is returned by a query.
|
1832
|
-
|
1833
|
-
Fixes #16463.
|
1834
|
-
|
1835
|
-
*Jason Nochlin*
|
1836
|
-
|
1837
|
-
* Ignore `.psqlrc` when loading database structure.
|
1838
|
-
|
1839
|
-
*Jason Weathered*
|
1840
|
-
|
1841
|
-
* Fix referencing wrong table aliases while joining tables of has many through
|
1842
|
-
association (only when calling calculation methods).
|
1843
|
-
|
1844
|
-
Fixes #19276.
|
1845
|
-
|
1846
|
-
*pinglamb*
|
1847
|
-
|
1848
|
-
* Correctly persist a serialized attribute that has been returned to
|
1849
|
-
its default value by an in-place modification.
|
1850
|
-
|
1851
|
-
Fixes #19467.
|
1852
|
-
|
1853
|
-
*Matthew Draper*
|
1854
|
-
|
1855
|
-
* Fix generating the schema file when using PostgreSQL `BigInt[]` data type.
|
1856
|
-
Previously the `limit: 8` was not coming through, and this caused it to
|
1857
|
-
become `Int[]` data type after rebuilding from the schema.
|
1858
|
-
|
1859
|
-
Fixes #19420.
|
1860
|
-
|
1861
|
-
*Jake Waller*
|
1862
|
-
|
1863
|
-
* Reuse the `CollectionAssociation#reader` cache when the foreign key is
|
1864
|
-
available prior to save.
|
1865
|
-
|
1866
|
-
*Ben Woosley*
|
1867
|
-
|
1868
|
-
* Add `config.active_record.dump_schemas` to fix `db:structure:dump`
|
1869
|
-
when using schema_search_path and PostgreSQL extensions.
|
1870
|
-
|
1871
|
-
Fixes #17157.
|
1872
|
-
|
1873
|
-
*Ryan Wallace*
|
1874
|
-
|
1875
|
-
* Renaming `use_transactional_fixtures` to `use_transactional_tests` for clarity.
|
1876
|
-
|
1877
|
-
Fixes #18864.
|
1878
|
-
|
1879
|
-
*Brandon Weiss*
|
1880
|
-
|
1881
|
-
* Increase pg gem version requirement to `~> 0.18`. Earlier versions of the
|
1882
|
-
pg gem are known to have problems with Ruby 2.2.
|
1883
|
-
|
1884
|
-
*Matt Brictson*
|
1885
|
-
|
1886
|
-
* Correctly dump `serial` and `bigserial`.
|
1887
|
-
|
1888
|
-
*Ryuta Kamizono*
|
1889
|
-
|
1890
|
-
* Fix default `format` value in `ActiveRecord::Tasks::DatabaseTasks#schema_file`.
|
1891
|
-
|
1892
|
-
*James Cox*
|
1893
|
-
|
1894
|
-
* Don't enroll records in the transaction if they don't have commit callbacks.
|
1895
|
-
This was causing a memory leak when creating many records inside a transaction.
|
1896
|
-
|
1897
|
-
Fixes #15549.
|
1898
|
-
|
1899
|
-
*Will Bryant*, *Aaron Patterson*
|
1900
|
-
|
1901
|
-
* Correctly create through records when created on a has many through
|
1902
|
-
association when using `where`.
|
1903
|
-
|
1904
|
-
Fixes #19073.
|
1905
|
-
|
1906
|
-
*Sean Griffin*
|
1907
|
-
|
1908
|
-
* Add `SchemaMigration.create_table` support for any unicode charsets with MySQL.
|
1909
|
-
|
1910
|
-
*Ryuta Kamizono*
|
1911
|
-
|
1912
|
-
* PostgreSQL no longer disables user triggers if system triggers can't be
|
1913
|
-
disabled. Disabling user triggers does not fulfill what the method promises.
|
1914
|
-
Rails currently requires superuser privileges for this method.
|
1915
|
-
|
1916
|
-
If you absolutely rely on this behavior, consider patching
|
1917
|
-
`disable_referential_integrity`.
|
1918
|
-
|
1919
|
-
*Yves Senn*
|
1920
|
-
|
1921
|
-
* Restore aborted transaction state when `disable_referential_integrity` fails
|
1922
|
-
due to missing permissions.
|
1923
|
-
|
1924
|
-
*Toby Ovod-Everett*, *Yves Senn*
|
1925
|
-
|
1926
|
-
* In PostgreSQL, print a warning message if `disable_referential_integrity`
|
1927
|
-
fails due to missing permissions.
|
1928
|
-
|
1929
|
-
*Andrey Nering*, *Yves Senn*
|
1930
|
-
|
1931
|
-
* Allow a `:limit` option for MySQL bigint primary key support.
|
1932
|
-
|
1933
|
-
Example:
|
1934
|
-
|
1935
|
-
create_table :foos, id: :primary_key, limit: 8 do |t|
|
1936
|
-
end
|
1937
|
-
|
1938
|
-
# or
|
1939
|
-
|
1940
|
-
create_table :foos, id: false do |t|
|
1941
|
-
t.primary_key :id, limit: 8
|
1942
|
-
end
|
1943
|
-
|
1944
|
-
*Ryuta Kamizono*
|
1945
|
-
|
1946
|
-
* `belongs_to` will now trigger a validation error by default if the association is not present.
|
1947
|
-
You can turn this off on a per-association basis with `optional: true`.
|
1948
|
-
(Note this new default only applies to new Rails apps that will be generated with
|
1949
|
-
`config.active_record.belongs_to_required_by_default = true` in initializer.)
|
1950
|
-
|
1951
|
-
*Josef Šimánek*
|
1952
|
-
|
1953
|
-
* Fixed `ActiveRecord::Relation#becomes!` and `changed_attributes` issues for type
|
1954
|
-
columns.
|
1955
|
-
|
1956
|
-
Fixes #17139.
|
1957
|
-
|
1958
|
-
*Miklos Fazekas*
|
1959
|
-
|
1960
|
-
* Format the time string according to the precision of the time column.
|
1961
|
-
|
1962
|
-
*Ryuta Kamizono*
|
1963
|
-
|
1964
|
-
* Allow a `:precision` option for time type columns.
|
1965
|
-
|
1966
|
-
*Ryuta Kamizono*
|
1967
|
-
|
1968
|
-
* Add `ActiveRecord::Base.suppress` to prevent the receiver from being saved
|
1969
|
-
during the given block.
|
1970
|
-
|
1971
|
-
For example, here's a pattern of creating notifications when new comments
|
1972
|
-
are posted. (The notification may in turn trigger an email, a push
|
1973
|
-
notification, or just appear in the UI somewhere):
|
1974
|
-
|
1975
|
-
class Comment < ActiveRecord::Base
|
1976
|
-
belongs_to :commentable, polymorphic: true
|
1977
|
-
after_create -> { Notification.create! comment: self,
|
1978
|
-
recipients: commentable.recipients }
|
1979
|
-
end
|
1980
|
-
|
1981
|
-
That's what you want the bulk of the time. A new comment creates a new
|
1982
|
-
Notification. There may be edge cases where you don't want that, like
|
1983
|
-
when copying a commentable and its comments, in which case write a
|
1984
|
-
concern with something like this:
|
1985
|
-
|
1986
|
-
module Copyable
|
1987
|
-
def copy_to(destination)
|
1988
|
-
Notification.suppress do
|
1989
|
-
# Copy logic that creates new comments that we do not want triggering
|
1990
|
-
# notifications.
|
1991
|
-
end
|
1992
|
-
end
|
1993
|
-
end
|
1994
|
-
|
1995
|
-
*Michael Ryan*
|
1996
|
-
|
1997
|
-
* `:time` option added for `#touch`.
|
1998
|
-
|
1999
|
-
Fixes #18905.
|
2000
|
-
|
2001
|
-
*Hyonjee Joo*
|
2002
|
-
|
2003
|
-
* Add `foreign_key_exists?` method.
|
2004
|
-
|
2005
|
-
*Tõnis Simo*
|
2006
|
-
|
2007
|
-
* Use SQL COUNT and LIMIT 1 queries for `none?` and `one?` methods
|
2008
|
-
if no block or limit is given, instead of loading the entire
|
2009
|
-
collection into memory. This applies to relations (e.g. `User.all`)
|
2010
|
-
as well as associations (e.g. `account.users`)
|
2011
|
-
|
2012
|
-
# Before:
|
2013
|
-
|
2014
|
-
users.none?
|
2015
|
-
# SELECT "users".* FROM "users"
|
2016
|
-
|
2017
|
-
users.one?
|
2018
|
-
# SELECT "users".* FROM "users"
|
2019
|
-
|
2020
|
-
# After:
|
2021
|
-
|
2022
|
-
users.none?
|
2023
|
-
# SELECT 1 AS one FROM "users" LIMIT 1
|
2024
|
-
|
2025
|
-
users.one?
|
2026
|
-
# SELECT COUNT(*) FROM "users"
|
2027
|
-
|
2028
|
-
*Eugene Gilburg*
|
2029
|
-
|
2030
|
-
* Have `enum` perform type casting consistently with the rest of Active
|
2031
|
-
Record, such as `where`.
|
2032
|
-
|
2033
|
-
*Sean Griffin*
|
2034
|
-
|
2035
|
-
* `scoping` no longer pollutes the current scope of sibling classes when using
|
2036
|
-
STI.
|
2037
|
-
|
2038
|
-
Fixes #18806.
|
2039
|
-
|
2040
|
-
Example:
|
2041
|
-
|
2042
|
-
StiOne.none.scoping do
|
2043
|
-
StiTwo.all
|
2044
|
-
end
|
2045
|
-
|
2046
|
-
|
2047
|
-
*Sean Griffin*
|
2048
|
-
|
2049
|
-
* `remove_reference` with `foreign_key: true` removes the foreign key before
|
2050
|
-
removing the column. This fixes a bug where it was not possible to remove
|
2051
|
-
the column on MySQL.
|
2052
|
-
|
2053
|
-
Fixes #18664.
|
2054
|
-
|
2055
|
-
*Yves Senn*
|
2056
|
-
|
2057
|
-
* `find_in_batches` now accepts an `:finish` parameter that complements the `:start`
|
2058
|
-
parameter to specify where to stop batch processing.
|
2059
|
-
|
2060
|
-
*Vipul A M*
|
2061
|
-
|
2062
|
-
* Fix a rounding problem for PostgreSQL timestamp columns.
|
2063
|
-
|
2064
|
-
If a timestamp column has a precision specified, it needs to
|
2065
|
-
format according to that.
|
2066
|
-
|
2067
|
-
*Ryuta Kamizono*
|
2068
|
-
|
2069
|
-
* Respect the database default charset for `schema_migrations` table.
|
2070
|
-
|
2071
|
-
The charset of `version` column in `schema_migrations` table depends
|
2072
|
-
on the database default charset and collation rather than the encoding
|
2073
|
-
of the connection.
|
2074
|
-
|
2075
|
-
*Ryuta Kamizono*
|
2076
|
-
|
2077
|
-
* Raise `ArgumentError` when passing `nil` or `false` to `Relation#merge`.
|
2078
|
-
|
2079
|
-
These are not valid values to merge in a relation, so it should warn users
|
2080
|
-
early.
|
2081
|
-
|
2082
|
-
*Rafael Mendonça França*
|
2083
|
-
|
2084
|
-
* Use `SCHEMA` instead of `DB_STRUCTURE` for specifying a structure file.
|
2085
|
-
|
2086
|
-
This makes the `db:structure` tasks consistent with `test:load_structure`.
|
2087
|
-
|
2088
|
-
*Dieter Komendera*
|
2089
|
-
|
2090
|
-
* Respect custom primary keys for associations when calling `Relation#where`
|
2091
|
-
|
2092
|
-
Fixes #18813.
|
2093
|
-
|
2094
|
-
*Sean Griffin*
|
2095
|
-
|
2096
|
-
* Fix several edge cases which could result in a counter cache updating
|
2097
|
-
twice or not updating at all for `has_many` and `has_many :through`.
|
2098
|
-
|
2099
|
-
Fixes #10865.
|
2100
|
-
|
2101
|
-
*Sean Griffin*
|
2102
|
-
|
2103
|
-
* Foreign keys added by migrations were given random, generated names. This
|
2104
|
-
meant a different `structure.sql` would be generated every time a developer
|
2105
|
-
ran migrations on their machine.
|
2106
|
-
|
2107
|
-
The generated part of foreign key names is now a hash of the table name and
|
2108
|
-
column name, which is consistent every time you run the migration.
|
2109
|
-
|
2110
|
-
*Chris Sinjakli*
|
2111
|
-
|
2112
|
-
* Fix n+1 query problem when eager loading nil associations (fixes #18312)
|
2113
|
-
|
2114
|
-
*Sammy Larbi*
|
2115
|
-
|
2116
|
-
* Change the default error message from `can't be blank` to `must exist` for
|
2117
|
-
the presence validator of the `:required` option on `belongs_to`/`has_one`
|
2118
|
-
associations.
|
2119
|
-
|
2120
|
-
*Henrik Nygren*
|
2121
|
-
|
2122
|
-
* Fixed `ActiveRecord::Relation#group` method when an argument is an SQL
|
2123
|
-
reserved keyword:
|
2124
|
-
|
2125
|
-
Example:
|
2126
|
-
|
2127
|
-
SplitTest.group(:key).count
|
2128
|
-
Property.group(:value).count
|
1191
|
+
* Add `ActiveRecord::Base.base_class?` predicate.
|
2129
1192
|
|
2130
1193
|
*Bogdan Gusiev*
|
2131
1194
|
|
2132
|
-
*
|
2133
|
-
operator to combine WHERE or HAVING clauses.
|
2134
|
-
|
2135
|
-
Example:
|
2136
|
-
|
2137
|
-
Post.where('id = 1').or(Post.where('id = 2'))
|
2138
|
-
# => SELECT * FROM posts WHERE (id = 1) OR (id = 2)
|
2139
|
-
|
2140
|
-
*Sean Griffin*, *Matthew Draper*, *Gael Muller*, *Olivier El Mekki*
|
2141
|
-
|
2142
|
-
* Don't define autosave association callbacks twice from
|
2143
|
-
`accepts_nested_attributes_for`.
|
2144
|
-
|
2145
|
-
Fixes #18704.
|
2146
|
-
|
2147
|
-
*Sean Griffin*
|
2148
|
-
|
2149
|
-
* Integer types will no longer raise a `RangeError` when assigning an
|
2150
|
-
attribute, but will instead raise when going to the database.
|
2151
|
-
|
2152
|
-
Fixes several vague issues which were never reported directly. See the
|
2153
|
-
commit message from the commit which added this line for some examples.
|
2154
|
-
|
2155
|
-
*Sean Griffin*
|
2156
|
-
|
2157
|
-
* Values which would error while being sent to the database (such as an
|
2158
|
-
ASCII-8BIT string with invalid UTF-8 bytes on SQLite3), no longer error on
|
2159
|
-
assignment. They will still error when sent to the database, but you are
|
2160
|
-
given the ability to re-assign it to a valid value.
|
2161
|
-
|
2162
|
-
Fixes #18580.
|
2163
|
-
|
2164
|
-
*Sean Griffin*
|
2165
|
-
|
2166
|
-
* Don't remove join dependencies in `Relation#exists?`
|
2167
|
-
|
2168
|
-
Fixes #18632.
|
2169
|
-
|
2170
|
-
*Sean Griffin*
|
2171
|
-
|
2172
|
-
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
2173
|
-
|
2174
|
-
Fixes #18629.
|
2175
|
-
|
2176
|
-
*Sean Griffin*
|
2177
|
-
|
2178
|
-
* Add `ActiveRecord::Base#accessed_fields`, which can be used to quickly
|
2179
|
-
discover which fields were read from a model when you are looking to only
|
2180
|
-
select the data you need from the database.
|
2181
|
-
|
2182
|
-
*Sean Griffin*
|
2183
|
-
|
2184
|
-
* Introduce the `:if_exists` option for `drop_table`.
|
2185
|
-
|
2186
|
-
Example:
|
2187
|
-
|
2188
|
-
drop_table(:posts, if_exists: true)
|
2189
|
-
|
2190
|
-
That would execute:
|
2191
|
-
|
2192
|
-
DROP TABLE IF EXISTS posts
|
2193
|
-
|
2194
|
-
If the table doesn't exist, `if_exists: false` (the default) raises an
|
2195
|
-
exception whereas `if_exists: true` does nothing.
|
2196
|
-
|
2197
|
-
*Cody Cutrer*, *Stefan Kanev*, *Ryuta Kamizono*
|
2198
|
-
|
2199
|
-
* Don't run SQL if attribute value is not changed for update_attribute method.
|
2200
|
-
|
2201
|
-
*Prathamesh Sonpatki*
|
2202
|
-
|
2203
|
-
* `time` columns can now get affected by `time_zone_aware_attributes`. If you have
|
2204
|
-
set `config.time_zone` to a value other than `'UTC'`, they will be treated
|
2205
|
-
as in that time zone by default in Rails 5.1. If this is not the desired
|
2206
|
-
behavior, you can set
|
2207
|
-
|
2208
|
-
ActiveRecord::Base.time_zone_aware_types = [:datetime]
|
2209
|
-
|
2210
|
-
A deprecation warning will be emitted if you have a `:time` column, and have
|
2211
|
-
not explicitly opted out.
|
2212
|
-
|
2213
|
-
Fixes #3145.
|
2214
|
-
|
2215
|
-
*Sean Griffin*
|
2216
|
-
|
2217
|
-
* Tests now run after_commit callbacks. You no longer have to declare
|
2218
|
-
`uses_transaction ‘test name’` to test the results of an after_commit.
|
2219
|
-
|
2220
|
-
after_commit callbacks run after committing a transaction whose parent
|
2221
|
-
is not `joinable?`: un-nested transactions, transactions within test cases,
|
2222
|
-
and transactions in `console --sandbox`.
|
2223
|
-
|
2224
|
-
*arthurnn*, *Ravil Bayramgalin*, *Matthew Draper*
|
2225
|
-
|
2226
|
-
* `nil` as a value for a binary column in a query no longer logs as
|
2227
|
-
"<NULL binary data>", and instead logs as just "nil".
|
2228
|
-
|
2229
|
-
*Sean Griffin*
|
2230
|
-
|
2231
|
-
* `attribute_will_change!` will no longer cause non-persistable attributes to
|
2232
|
-
be sent to the database.
|
2233
|
-
|
2234
|
-
Fixes #18407.
|
2235
|
-
|
2236
|
-
*Sean Griffin*
|
2237
|
-
|
2238
|
-
* Remove support for the `protected_attributes` gem.
|
2239
|
-
|
2240
|
-
*Carlos Antonio da Silva*, *Roberto Miranda*
|
2241
|
-
|
2242
|
-
* Fix accessing of fixtures having non-string labels like Fixnum.
|
2243
|
-
|
2244
|
-
*Prathamesh Sonpatki*
|
2245
|
-
|
2246
|
-
* Remove deprecated support to preload instance-dependent associations.
|
2247
|
-
|
2248
|
-
*Yves Senn*
|
2249
|
-
|
2250
|
-
* Remove deprecated support for PostgreSQL ranges with exclusive lower bounds.
|
2251
|
-
|
2252
|
-
*Yves Senn*
|
2253
|
-
|
2254
|
-
* Remove deprecation when modifying a relation with cached Arel.
|
2255
|
-
This raises an `ImmutableRelation` error instead.
|
2256
|
-
|
2257
|
-
*Yves Senn*
|
2258
|
-
|
2259
|
-
* Added `ActiveRecord::SecureToken` in order to encapsulate generation of
|
2260
|
-
unique tokens for attributes in a model using `SecureRandom`.
|
2261
|
-
|
2262
|
-
*Roberto Miranda*
|
2263
|
-
|
2264
|
-
* Change the behavior of boolean columns to be closer to Ruby's semantics.
|
2265
|
-
|
2266
|
-
Before this change we had a small set of "truthy", and all others are "falsy".
|
2267
|
-
|
2268
|
-
Now, we have a small set of "falsy" values and all others are "truthy" matching
|
2269
|
-
Ruby's semantics.
|
2270
|
-
|
2271
|
-
*Rafael Mendonça França*
|
2272
|
-
|
2273
|
-
* Deprecate `ActiveRecord::Base.errors_in_transactional_callbacks=`.
|
2274
|
-
|
2275
|
-
*Rafael Mendonça França*
|
2276
|
-
|
2277
|
-
* Change transaction callbacks to not swallow errors.
|
2278
|
-
|
2279
|
-
Before this change any errors raised inside a transaction callback
|
2280
|
-
were getting rescued and printed in the logs.
|
2281
|
-
|
2282
|
-
Now these errors are not rescued anymore and just bubble up, as the other callbacks.
|
2283
|
-
|
2284
|
-
*Rafael Mendonça França*
|
2285
|
-
|
2286
|
-
* Remove deprecated `sanitize_sql_hash_for_conditions`.
|
2287
|
-
|
2288
|
-
*Rafael Mendonça França*
|
2289
|
-
|
2290
|
-
* Remove deprecated `Reflection#source_macro`.
|
2291
|
-
|
2292
|
-
*Rafael Mendonça França*
|
2293
|
-
|
2294
|
-
* Remove deprecated `symbolized_base_class` and `symbolized_sti_name`.
|
2295
|
-
|
2296
|
-
*Rafael Mendonça França*
|
2297
|
-
|
2298
|
-
* Remove deprecated `ActiveRecord::Base.disable_implicit_join_references=`.
|
2299
|
-
|
2300
|
-
*Rafael Mendonça França*
|
2301
|
-
|
2302
|
-
* Remove deprecated access to connection specification using a string accessor.
|
2303
|
-
|
2304
|
-
Now all strings will be handled as a URL.
|
2305
|
-
|
2306
|
-
*Rafael Mendonça França*
|
2307
|
-
|
2308
|
-
* Change the default `null` value for `timestamps` to `false`.
|
2309
|
-
|
2310
|
-
*Rafael Mendonça França*
|
2311
|
-
|
2312
|
-
* Return an array of pools from `connection_pools`.
|
2313
|
-
|
2314
|
-
*Rafael Mendonça França*
|
2315
|
-
|
2316
|
-
* Return a null column from `column_for_attribute` when no column exists.
|
2317
|
-
|
2318
|
-
*Rafael Mendonça França*
|
2319
|
-
|
2320
|
-
* Remove deprecated `serialized_attributes`.
|
2321
|
-
|
2322
|
-
*Rafael Mendonça França*
|
2323
|
-
|
2324
|
-
* Remove deprecated automatic counter caches on `has_many :through`.
|
2325
|
-
|
2326
|
-
*Rafael Mendonça França*
|
2327
|
-
|
2328
|
-
* Change the way in which callback chains can be halted.
|
2329
|
-
|
2330
|
-
The preferred method to halt a callback chain from now on is to explicitly
|
2331
|
-
`throw(:abort)`.
|
2332
|
-
In the past, returning `false` in an Active Record `before_` callback had the
|
2333
|
-
side effect of halting the callback chain.
|
2334
|
-
This is not recommended anymore and, depending on the value of the
|
2335
|
-
`ActiveSupport.halt_callback_chains_on_return_false` option, will
|
2336
|
-
either not work at all or display a deprecation warning.
|
2337
|
-
|
2338
|
-
*claudiob*
|
2339
|
-
|
2340
|
-
* Clear query cache on rollback.
|
2341
|
-
|
2342
|
-
*Florian Weingarten*
|
2343
|
-
|
2344
|
-
* Fix setting of foreign_key for through associations when building a new record.
|
2345
|
-
|
2346
|
-
Fixes #12698.
|
2347
|
-
|
2348
|
-
*Ivan Antropov*
|
2349
|
-
|
2350
|
-
* Improve dumping of the primary key. If it is not a default primary key,
|
2351
|
-
correctly dump the type and options.
|
2352
|
-
|
2353
|
-
Fixes #14169, #16599.
|
2354
|
-
|
2355
|
-
*Ryuta Kamizono*
|
2356
|
-
|
2357
|
-
* Format the datetime string according to the precision of the datetime field.
|
2358
|
-
|
2359
|
-
Incompatible to rounding behavior between MySQL 5.6 and earlier.
|
2360
|
-
|
2361
|
-
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
|
2362
|
-
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
2363
|
-
|
2364
|
-
http://bugs.mysql.com/bug.php?id=68760
|
2365
|
-
|
2366
|
-
*Ryuta Kamizono*
|
2367
|
-
|
2368
|
-
* Allow a precision option for MySQL datetimes.
|
2369
|
-
|
2370
|
-
*Ryuta Kamizono*
|
2371
|
-
|
2372
|
-
* Fixed automatic `inverse_of` for models nested in a module.
|
2373
|
-
|
2374
|
-
*Andrew McCloud*
|
2375
|
-
|
2376
|
-
* Change `ActiveRecord::Relation#update` behavior so that it can
|
2377
|
-
be called without passing ids of the records to be updated.
|
2378
|
-
|
2379
|
-
This change allows updating multiple records returned by
|
2380
|
-
`ActiveRecord::Relation` with callbacks and validations.
|
2381
|
-
|
2382
|
-
# Before
|
2383
|
-
# ArgumentError: wrong number of arguments (1 for 2)
|
2384
|
-
Comment.where(group: 'expert').update(body: "Group of Rails Experts")
|
2385
|
-
|
2386
|
-
# After
|
2387
|
-
# Comments with group expert updated with body "Group of Rails Experts"
|
2388
|
-
Comment.where(group: 'expert').update(body: "Group of Rails Experts")
|
2389
|
-
|
2390
|
-
*Prathamesh Sonpatki*
|
2391
|
-
|
2392
|
-
* Fix `reaping_frequency` option when the value is a string.
|
2393
|
-
|
2394
|
-
This usually happens when it is configured using `DATABASE_URL`.
|
2395
|
-
|
2396
|
-
*korbin*
|
2397
|
-
|
2398
|
-
* Fix error message when trying to create an associated record and the foreign
|
2399
|
-
key is missing.
|
2400
|
-
|
2401
|
-
Before this fix the following exception was being raised:
|
2402
|
-
|
2403
|
-
NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
|
2404
|
-
|
2405
|
-
Now the message is:
|
2406
|
-
|
2407
|
-
ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
|
2408
|
-
|
2409
|
-
*Rafael Mendonça França*
|
2410
|
-
|
2411
|
-
* Fix change detection problem for PostgreSQL bytea type and
|
2412
|
-
`ArgumentError: string contains null byte` exception with pg-0.18.
|
2413
|
-
|
2414
|
-
Fixes #17680.
|
2415
|
-
|
2416
|
-
*Lars Kanis*
|
2417
|
-
|
2418
|
-
* When a table has a composite primary key, the `primary_key` method for
|
2419
|
-
SQLite3 and PostgreSQL adapters was only returning the first field of the key.
|
2420
|
-
Ensures that it will return nil instead, as Active Record doesn't support
|
2421
|
-
composite primary keys.
|
2422
|
-
|
2423
|
-
Fixes #18070.
|
2424
|
-
|
2425
|
-
*arthurnn*
|
2426
|
-
|
2427
|
-
* `validates_size_of` / `validates_length_of` do not count records
|
2428
|
-
which are `marked_for_destruction?`.
|
2429
|
-
|
2430
|
-
Fixes #7247.
|
2431
|
-
|
2432
|
-
*Yves Senn*
|
2433
|
-
|
2434
|
-
* Ensure `first!` and friends work on loaded associations.
|
2435
|
-
|
2436
|
-
Fixes #18237.
|
2437
|
-
|
2438
|
-
*Sean Griffin*
|
2439
|
-
|
2440
|
-
* `eager_load` preserves readonly flag for associations.
|
2441
|
-
|
2442
|
-
Fixes #15853.
|
2443
|
-
|
2444
|
-
*Takashi Kokubun*
|
2445
|
-
|
2446
|
-
* Provide `:touch` option to `save()` to accommodate saving without updating
|
2447
|
-
timestamps.
|
2448
|
-
|
2449
|
-
Fixes #18202.
|
2450
|
-
|
2451
|
-
*Dan Olson*
|
2452
|
-
|
2453
|
-
* Provide a more helpful error message when an unsupported class is passed to
|
2454
|
-
`serialize`.
|
2455
|
-
|
2456
|
-
Fixes #18224.
|
2457
|
-
|
2458
|
-
*Sean Griffin*
|
2459
|
-
|
2460
|
-
* Add bigint primary key support for MySQL.
|
2461
|
-
|
2462
|
-
Example:
|
2463
|
-
|
2464
|
-
create_table :foos, id: :bigint do |t|
|
2465
|
-
end
|
2466
|
-
|
2467
|
-
*Ryuta Kamizono*
|
2468
|
-
|
2469
|
-
* Support for any type of primary key.
|
2470
|
-
|
2471
|
-
Fixes #14194.
|
2472
|
-
|
2473
|
-
*Ryuta Kamizono*
|
2474
|
-
|
2475
|
-
* Dump the default `nil` for PostgreSQL UUID primary key.
|
2476
|
-
|
2477
|
-
*Ryuta Kamizono*
|
2478
|
-
|
2479
|
-
* Add a `:foreign_key` option to `references` and associated migration
|
2480
|
-
methods. The model and migration generators now use this option, rather than
|
2481
|
-
the `add_foreign_key` form.
|
2482
|
-
|
2483
|
-
*Sean Griffin*
|
2484
|
-
|
2485
|
-
* Don't raise when writing an attribute with an out-of-range datetime passed
|
2486
|
-
by the user.
|
2487
|
-
|
2488
|
-
*Grey Baker*
|
2489
|
-
|
2490
|
-
* Replace deprecated `ActiveRecord::Tasks::DatabaseTasks#load_schema` with
|
2491
|
-
`ActiveRecord::Tasks::DatabaseTasks#load_schema_for`.
|
2492
|
-
|
2493
|
-
*Yves Senn*
|
2494
|
-
|
2495
|
-
* Fix bug with `ActiveRecord::Type::Numeric` that caused negative values to
|
2496
|
-
be marked as having changed when set to the same negative value.
|
2497
|
-
|
2498
|
-
Fixes #18161.
|
2499
|
-
|
2500
|
-
*Daniel Fox*
|
2501
|
-
|
2502
|
-
* Introduce `force: :cascade` option for `create_table`. Using this option
|
2503
|
-
will recreate tables even if they have dependent objects (like foreign keys).
|
2504
|
-
`db/schema.rb` now uses `force: :cascade`. This makes it possible to
|
2505
|
-
reload the schema when foreign keys are in place.
|
2506
|
-
|
2507
|
-
*Matthew Draper*, *Yves Senn*
|
2508
|
-
|
2509
|
-
* `db:schema:load` and `db:structure:load` no longer purge the database
|
2510
|
-
before loading the schema. This is left for the user to do.
|
2511
|
-
`db:test:prepare` will still purge the database.
|
2512
|
-
|
2513
|
-
Fixes #17945.
|
2514
|
-
|
2515
|
-
*Yves Senn*
|
2516
|
-
|
2517
|
-
* Fix undesirable RangeError by `Type::Integer`. Add `Type::UnsignedInteger`.
|
2518
|
-
|
2519
|
-
*Ryuta Kamizono*
|
2520
|
-
|
2521
|
-
* Add `foreign_type` option to `has_one` and `has_many` association macros.
|
1195
|
+
* Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
|
2522
1196
|
|
2523
|
-
|
1197
|
+
*Tan Huynh*, *Yukio Mizuta*
|
2524
1198
|
|
2525
|
-
|
1199
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
2526
1200
|
|
2527
|
-
*
|
2528
|
-
values.
|
1201
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
2529
1202
|
|
2530
|
-
|
1203
|
+
* Deprecate `update_attributes`/`!` in favor of `update`/`!`.
|
2531
1204
|
|
2532
|
-
*
|
2533
|
-
instead.
|
1205
|
+
*Eddie Lebow*
|
2534
1206
|
|
2535
|
-
|
1207
|
+
* Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
|
1208
|
+
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
2536
1209
|
|
2537
|
-
*
|
2538
|
-
options.
|
1210
|
+
*DHH*
|
2539
1211
|
|
2540
|
-
|
1212
|
+
* Add `Relation#pick` as short-hand for single-value plucks.
|
2541
1213
|
|
2542
|
-
*
|
2543
|
-
`ActiveRecord::ConnectionAdapters::ColumnDumper#prepare_column_options` no
|
2544
|
-
longer have a `types` argument. They should access
|
2545
|
-
`connection#native_database_types` directly.
|
1214
|
+
*DHH*
|
2546
1215
|
|
2547
|
-
*Yves Senn*
|
2548
1216
|
|
2549
|
-
Please check [
|
1217
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
|