activerecord 4.2.9 → 6.1.4.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +964 -1382
- data/MIT-LICENSE +4 -2
- data/README.rdoc +15 -14
- data/examples/performance.rb +33 -32
- data/examples/simple.rb +5 -4
- data/lib/active_record/aggregations.rb +266 -251
- data/lib/active_record/association_relation.rb +40 -15
- data/lib/active_record/associations/alias_tracker.rb +40 -43
- data/lib/active_record/associations/association.rb +162 -69
- data/lib/active_record/associations/association_scope.rb +105 -130
- data/lib/active_record/associations/belongs_to_association.rb +83 -65
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +13 -12
- data/lib/active_record/associations/builder/association.rb +57 -43
- data/lib/active_record/associations/builder/belongs_to.rb +74 -57
- data/lib/active_record/associations/builder/collection_association.rb +15 -37
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +49 -66
- data/lib/active_record/associations/builder/has_many.rb +13 -5
- data/lib/active_record/associations/builder/has_one.rb +44 -6
- data/lib/active_record/associations/builder/singular_association.rb +16 -10
- data/lib/active_record/associations/collection_association.rb +148 -287
- data/lib/active_record/associations/collection_proxy.rb +252 -150
- data/lib/active_record/associations/foreign_association.rb +23 -1
- data/lib/active_record/associations/has_many_association.rb +56 -98
- data/lib/active_record/associations/has_many_through_association.rb +68 -89
- data/lib/active_record/associations/has_one_association.rb +73 -47
- data/lib/active_record/associations/has_one_through_association.rb +20 -11
- data/lib/active_record/associations/join_dependency/join_association.rb +54 -81
- data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
- data/lib/active_record/associations/join_dependency/join_part.rb +14 -14
- data/lib/active_record/associations/join_dependency.rb +174 -169
- data/lib/active_record/associations/preloader/association.rb +108 -115
- data/lib/active_record/associations/preloader/through_association.rb +85 -65
- data/lib/active_record/associations/preloader.rb +97 -94
- data/lib/active_record/associations/singular_association.rb +18 -39
- data/lib/active_record/associations/through_association.rb +39 -19
- data/lib/active_record/associations.rb +1845 -1598
- data/lib/active_record/attribute_assignment.rb +59 -185
- data/lib/active_record/attribute_methods/before_type_cast.rb +18 -10
- data/lib/active_record/attribute_methods/dirty.rb +168 -148
- data/lib/active_record/attribute_methods/primary_key.rb +93 -83
- data/lib/active_record/attribute_methods/query.rb +8 -10
- data/lib/active_record/attribute_methods/read.rb +19 -79
- data/lib/active_record/attribute_methods/serialization.rb +49 -24
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +55 -36
- data/lib/active_record/attribute_methods/write.rb +24 -55
- data/lib/active_record/attribute_methods.rb +149 -154
- data/lib/active_record/attributes.rb +234 -78
- data/lib/active_record/autosave_association.rb +133 -60
- data/lib/active_record/base.rb +46 -46
- data/lib/active_record/callbacks.rb +234 -79
- data/lib/active_record/coders/json.rb +3 -1
- data/lib/active_record/coders/yaml_column.rb +34 -13
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +887 -323
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +17 -41
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +292 -124
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +78 -24
- data/lib/active_record/connection_adapters/abstract/quoting.rb +177 -60
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +8 -6
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +157 -93
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +473 -255
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +79 -36
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +869 -286
- data/lib/active_record/connection_adapters/abstract/transaction.rb +257 -91
- data/lib/active_record/connection_adapters/abstract_adapter.rb +483 -230
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +557 -640
- data/lib/active_record/connection_adapters/column.rb +67 -40
- data/lib/active_record/connection_adapters/deduplicable.rb +29 -0
- data/lib/active_record/connection_adapters/legacy_pool_manager.rb +35 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +27 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +194 -0
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +71 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +96 -0
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +97 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +103 -0
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +91 -0
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +268 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +40 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +80 -192
- data/lib/active_record/connection_adapters/pool_config.rb +73 -0
- data/lib/active_record/connection_adapters/pool_manager.rb +47 -0
- data/lib/active_record/connection_adapters/postgresql/column.rb +44 -11
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +75 -160
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +49 -58
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +9 -8
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +8 -6
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +13 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +14 -19
- 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 +31 -20
- data/lib/active_record/connection_adapters/postgresql/oid/inet.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/interval.rb +49 -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/macaddr.rb +25 -0
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +7 -9
- data/lib/active_record/connection_adapters/postgresql/oid/{infinity.rb → oid.rb} +5 -3
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +32 -11
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +70 -34
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -5
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +58 -54
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +18 -4
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid.rb +25 -25
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +145 -48
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +27 -14
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +80 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +178 -108
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +49 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +496 -298
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +11 -8
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +588 -375
- data/lib/active_record/connection_adapters/schema_cache.rb +167 -29
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +45 -0
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +144 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +21 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +102 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +21 -0
- 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 +170 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +322 -373
- data/lib/active_record/connection_adapters/statement_pool.rb +33 -13
- data/lib/active_record/connection_adapters.rb +52 -0
- data/lib/active_record/connection_handling.rb +314 -41
- data/lib/active_record/core.rb +458 -241
- data/lib/active_record/counter_cache.rb +70 -49
- data/lib/active_record/database_configurations/connection_url_resolver.rb +98 -0
- data/lib/active_record/database_configurations/database_config.rb +80 -0
- data/lib/active_record/database_configurations/hash_config.rb +96 -0
- data/lib/active_record/database_configurations/url_config.rb +53 -0
- data/lib/active_record/database_configurations.rb +272 -0
- data/lib/active_record/delegated_type.rb +209 -0
- data/lib/active_record/destroy_association_async_job.rb +36 -0
- data/lib/active_record/dynamic_matchers.rb +87 -106
- data/lib/active_record/enum.rb +211 -92
- data/lib/active_record/errors.rb +224 -54
- data/lib/active_record/explain.rb +27 -11
- data/lib/active_record/explain_registry.rb +4 -2
- data/lib/active_record/explain_subscriber.rb +10 -5
- data/lib/active_record/fixture_set/file.rb +33 -14
- data/lib/active_record/fixture_set/model_metadata.rb +32 -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 +275 -500
- data/lib/active_record/gem_version.rb +6 -4
- data/lib/active_record/inheritance.rb +175 -110
- data/lib/active_record/insert_all.rb +212 -0
- data/lib/active_record/integration.rb +121 -29
- data/lib/active_record/internal_metadata.rb +62 -0
- data/lib/active_record/legacy_yaml_adapter.rb +27 -5
- data/lib/active_record/locale/en.yml +3 -2
- data/lib/active_record/locking/optimistic.rb +98 -92
- data/lib/active_record/locking/pessimistic.rb +22 -6
- data/lib/active_record/log_subscriber.rb +93 -31
- data/lib/active_record/middleware/database_selector/resolver/session.rb +48 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +92 -0
- data/lib/active_record/middleware/database_selector.rb +77 -0
- data/lib/active_record/migration/command_recorder.rb +185 -90
- data/lib/active_record/migration/compatibility.rb +295 -0
- data/lib/active_record/migration/join_table.rb +8 -7
- data/lib/active_record/migration.rb +673 -325
- data/lib/active_record/model_schema.rb +418 -113
- data/lib/active_record/nested_attributes.rb +263 -224
- data/lib/active_record/no_touching.rb +15 -2
- data/lib/active_record/null_relation.rb +24 -38
- data/lib/active_record/persistence.rb +572 -136
- data/lib/active_record/query_cache.rb +29 -23
- data/lib/active_record/querying.rb +50 -31
- data/lib/active_record/railtie.rb +170 -51
- data/lib/active_record/railties/console_sandbox.rb +3 -3
- data/lib/active_record/railties/controller_runtime.rb +34 -33
- data/lib/active_record/railties/databases.rake +523 -199
- data/lib/active_record/readonly_attributes.rb +9 -4
- data/lib/active_record/reflection.rb +454 -291
- data/lib/active_record/relation/batches/batch_enumerator.rb +85 -0
- data/lib/active_record/relation/batches.rb +217 -59
- data/lib/active_record/relation/calculations.rb +324 -249
- data/lib/active_record/relation/delegation.rb +76 -84
- data/lib/active_record/relation/finder_methods.rb +316 -242
- data/lib/active_record/relation/from_clause.rb +30 -0
- data/lib/active_record/relation/merger.rb +95 -103
- data/lib/active_record/relation/predicate_builder/array_handler.rb +26 -26
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +42 -0
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +19 -0
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +57 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +22 -0
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +7 -1
- data/lib/active_record/relation/predicate_builder.rb +136 -122
- data/lib/active_record/relation/query_attribute.rb +50 -0
- data/lib/active_record/relation/query_methods.rb +757 -413
- data/lib/active_record/relation/record_fetch_warning.rb +51 -0
- data/lib/active_record/relation/spawn_methods.rb +18 -20
- data/lib/active_record/relation/where_clause.rb +239 -0
- data/lib/active_record/relation.rb +554 -343
- data/lib/active_record/result.rb +91 -47
- data/lib/active_record/runtime_registry.rb +6 -4
- data/lib/active_record/sanitization.rb +134 -122
- data/lib/active_record/schema.rb +21 -24
- data/lib/active_record/schema_dumper.rb +141 -92
- data/lib/active_record/schema_migration.rb +24 -23
- data/lib/active_record/scoping/default.rb +96 -83
- data/lib/active_record/scoping/named.rb +78 -36
- data/lib/active_record/scoping.rb +45 -27
- data/lib/active_record/secure_token.rb +48 -0
- data/lib/active_record/serialization.rb +8 -6
- data/lib/active_record/signed_id.rb +116 -0
- data/lib/active_record/statement_cache.rb +89 -36
- data/lib/active_record/store.rb +128 -43
- data/lib/active_record/suppressor.rb +61 -0
- data/lib/active_record/table_metadata.rb +81 -0
- data/lib/active_record/tasks/database_tasks.rb +364 -130
- data/lib/active_record/tasks/mysql_database_tasks.rb +67 -113
- data/lib/active_record/tasks/postgresql_database_tasks.rb +86 -49
- data/lib/active_record/tasks/sqlite_database_tasks.rb +44 -19
- data/lib/active_record/test_databases.rb +24 -0
- data/lib/active_record/test_fixtures.rb +287 -0
- data/lib/active_record/timestamp.rb +86 -43
- data/lib/active_record/touch_later.rb +65 -0
- data/lib/active_record/transactions.rb +182 -163
- data/lib/active_record/translation.rb +3 -1
- data/lib/active_record/type/adapter_specific_registry.rb +126 -0
- data/lib/active_record/type/date.rb +4 -45
- data/lib/active_record/type/date_time.rb +4 -49
- data/lib/active_record/type/decimal_without_scale.rb +6 -2
- data/lib/active_record/type/hash_lookup_type_map.rb +5 -4
- data/lib/active_record/type/internal/timezone.rb +17 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +27 -15
- data/lib/active_record/type/text.rb +2 -2
- data/lib/active_record/type/time.rb +21 -16
- data/lib/active_record/type/type_map.rb +16 -19
- data/lib/active_record/type/unsigned_integer.rb +9 -8
- data/lib/active_record/type.rb +84 -23
- data/lib/active_record/type_caster/connection.rb +33 -0
- data/lib/active_record/type_caster/map.rb +23 -0
- data/lib/active_record/type_caster.rb +9 -0
- data/lib/active_record/validations/absence.rb +25 -0
- data/lib/active_record/validations/associated.rb +12 -4
- data/lib/active_record/validations/length.rb +26 -0
- data/lib/active_record/validations/numericality.rb +35 -0
- data/lib/active_record/validations/presence.rb +14 -13
- data/lib/active_record/validations/uniqueness.rb +63 -56
- data/lib/active_record/validations.rb +39 -35
- data/lib/active_record/version.rb +3 -1
- data/lib/active_record.rb +42 -29
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes/attribute.rb +41 -0
- data/lib/arel/collectors/bind.rb +29 -0
- data/lib/arel/collectors/composite.rb +39 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +27 -0
- data/lib/arel/collectors/substitute_binds.rb +35 -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/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +126 -0
- data/lib/arel/nodes/bind_param.rb +44 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +62 -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 +15 -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 +11 -0
- data/lib/arel/nodes/homogeneous_in.rb +76 -0
- data/lib/arel/nodes/in.rb +15 -0
- data/lib/arel/nodes/infix_operation.rb +92 -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 +51 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/ordering.rb +27 -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 +19 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +31 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +44 -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/nodes.rb +70 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +250 -0
- data/lib/arel/select_manager.rb +270 -0
- data/lib/arel/table.rb +118 -0
- data/lib/arel/tree_manager.rb +72 -0
- data/lib/arel/update_manager.rb +34 -0
- data/lib/arel/visitors/dot.rb +308 -0
- data/lib/arel/visitors/mysql.rb +93 -0
- data/lib/arel/visitors/postgresql.rb +120 -0
- data/lib/arel/visitors/sqlite.rb +38 -0
- data/lib/arel/visitors/to_sql.rb +899 -0
- data/lib/arel/visitors/visitor.rb +45 -0
- data/lib/arel/visitors.rb +13 -0
- data/lib/arel/window_predications.rb +9 -0
- data/lib/arel.rb +54 -0
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +26 -0
- data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +5 -0
- data/lib/rails/generators/active_record/migration/migration_generator.rb +43 -37
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +26 -0
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +13 -4
- data/lib/rails/generators/active_record/migration.rb +35 -1
- data/lib/rails/generators/active_record/model/model_generator.rb +55 -22
- data/lib/rails/generators/active_record/model/templates/abstract_base_class.rb.tt +7 -0
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +22 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- data/lib/rails/generators/active_record.rb +7 -5
- metadata +172 -65
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -24
- 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 -23
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -21
- data/lib/active_record/attribute.rb +0 -163
- data/lib/active_record/attribute_decorators.rb +0 -66
- data/lib/active_record/attribute_set/builder.rb +0 -106
- data/lib/active_record/attribute_set.rb +0 -81
- data/lib/active_record/connection_adapters/connection_specification.rb +0 -275
- data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -491
- data/lib/active_record/connection_adapters/postgresql/array_parser.rb +0 -93
- data/lib/active_record/connection_adapters/postgresql/oid/float.rb +0 -21
- data/lib/active_record/connection_adapters/postgresql/oid/integer.rb +0 -11
- data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -35
- data/lib/active_record/connection_adapters/postgresql/oid/time.rb +0 -11
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/serializers/xml_serializer.rb +0 -193
- data/lib/active_record/type/big_integer.rb +0 -13
- data/lib/active_record/type/binary.rb +0 -50
- data/lib/active_record/type/boolean.rb +0 -31
- data/lib/active_record/type/decimal.rb +0 -64
- data/lib/active_record/type/decorator.rb +0 -14
- data/lib/active_record/type/float.rb +0 -19
- data/lib/active_record/type/integer.rb +0 -59
- data/lib/active_record/type/mutable.rb +0 -16
- data/lib/active_record/type/numeric.rb +0 -36
- data/lib/active_record/type/string.rb +0 -40
- data/lib/active_record/type/time_value.rb +0 -38
- data/lib/active_record/type/value.rb +0 -110
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +0 -19
- data/lib/rails/generators/active_record/model/templates/model.rb +0 -10
data/CHANGELOG.md
CHANGED
@@ -1,2014 +1,1596 @@
|
|
1
|
-
## Rails 4.
|
1
|
+
## Rails 6.1.4.1 (August 19, 2021) ##
|
2
2
|
|
3
|
-
*
|
4
|
-
|
5
|
-
*Nick Pezza*
|
6
|
-
|
7
|
-
* Fix `rake db:schema:load` with subdirectories.
|
8
|
-
|
9
|
-
*Ryuta Kamizono*
|
10
|
-
|
11
|
-
* Fix `rake db:migrate:status` with subdirectories.
|
12
|
-
|
13
|
-
*Ryuta Kamizono*
|
14
|
-
|
15
|
-
* Fix regression of #1969 with SELECT aliases in HAVING clause.
|
16
|
-
|
17
|
-
*Eugene Kenny*
|
18
|
-
|
19
|
-
* Fix `wait_timeout` to configurable for mysql2 adapter.
|
20
|
-
|
21
|
-
Fixes #26556.
|
22
|
-
|
23
|
-
*Ryuta Kamizono*
|
24
|
-
|
25
|
-
* Make `table_name=` reset current statement cache,
|
26
|
-
so queries are not run against the previous table name.
|
27
|
-
|
28
|
-
*namusyaka*
|
3
|
+
* No changes.
|
29
4
|
|
30
5
|
|
31
|
-
## Rails
|
6
|
+
## Rails 6.1.4 (June 24, 2021) ##
|
32
7
|
|
33
|
-
*
|
34
|
-
saying the connection is closed rather than an undefined method error message.
|
8
|
+
* Do not try to rollback transactions that failed due to a `ActiveRecord::TransactionRollbackError`.
|
35
9
|
|
36
|
-
*
|
10
|
+
*Jamie McCarthy*
|
37
11
|
|
38
|
-
*
|
12
|
+
* Raise an error if `pool_config` is `nil` in `set_pool_config`.
|
39
13
|
|
40
|
-
*
|
14
|
+
*Eileen M. Uchitelle*
|
41
15
|
|
42
|
-
* Fix
|
16
|
+
* Fix compatibility with `psych >= 4`.
|
43
17
|
|
44
|
-
|
18
|
+
Starting in Psych 4.0.0 `YAML.load` behaves like `YAML.safe_load`. To preserve compatibility
|
19
|
+
Active Record's schema cache loader and `YAMLColumn` now uses `YAML.unsafe_load` if available.
|
45
20
|
|
46
|
-
*
|
21
|
+
*Jean Boussier*
|
47
22
|
|
48
|
-
*
|
23
|
+
* Support using replicas when using `rails dbconsole`.
|
49
24
|
|
50
|
-
|
25
|
+
*Christopher Thornton*
|
51
26
|
|
52
|
-
|
27
|
+
* Restore connection pools after transactional tests.
|
53
28
|
|
54
|
-
*
|
55
|
-
mapping methods are methods implemented on `Hash`.
|
29
|
+
*Eugene Kenny*
|
56
30
|
|
57
|
-
|
31
|
+
* Change `upsert_all` to fails cleanly for MySQL when `:unique_by` is used.
|
58
32
|
|
59
|
-
*
|
33
|
+
*Bastian Bartmann*
|
60
34
|
|
35
|
+
* Fix user-defined `self.default_scope` to respect table alias.
|
61
36
|
|
62
|
-
|
37
|
+
*Ryuta Kamizono*
|
63
38
|
|
64
|
-
*
|
65
|
-
truncates the array, preventing `inspect` from looping infinitely in some
|
66
|
-
cases.
|
39
|
+
* Clear `@cache_keys` cache after `update_all`, `delete_all`, `destroy_all`.
|
67
40
|
|
68
|
-
*
|
41
|
+
*Ryuta Kamizono*
|
69
42
|
|
70
|
-
*
|
71
|
-
|
43
|
+
* Changed Arel predications `contains` and `overlaps` to use
|
44
|
+
`quoted_node` so that PostgreSQL arrays are quoted properly.
|
72
45
|
|
73
|
-
*
|
46
|
+
*Bradley Priest*
|
74
47
|
|
75
|
-
*
|
76
|
-
interpreted as `Computer.joins(:monitor).group('computers.status').count`
|
77
|
-
so that when `Computer` and `Monitor` have both `status` columns we don't
|
78
|
-
have conflicts in projection.
|
48
|
+
* Fix `merge` when the `where` clauses have string contents.
|
79
49
|
|
80
|
-
*
|
50
|
+
*Ryuta Kamizono*
|
81
51
|
|
82
|
-
*
|
83
|
-
are specified or an ActiveRecord::StatementInvalid when an invalid type
|
84
|
-
is provided for a column name (e.g. a Hash).
|
52
|
+
* Fix rollback of parent destruction with nested `dependent: :destroy`.
|
85
53
|
|
86
|
-
|
54
|
+
*Jacopo Beschi*
|
87
55
|
|
88
|
-
|
56
|
+
* Fix binds logging for `"WHERE ... IN ..."` statements.
|
89
57
|
|
90
|
-
*
|
58
|
+
*Ricardo Díaz*
|
91
59
|
|
92
|
-
|
60
|
+
* Handle `false` in relation strict loading checks.
|
93
61
|
|
94
|
-
|
62
|
+
Previously when a model had strict loading set to true and then had a
|
63
|
+
relation set `strict_loading` to false the false wasn't considered when
|
64
|
+
deciding whether to raise/warn about strict loading.
|
95
65
|
|
66
|
+
```
|
67
|
+
class Dog < ActiveRecord::Base
|
68
|
+
self.strict_loading_by_default = true
|
96
69
|
|
97
|
-
|
70
|
+
has_many :treats, strict_loading: false
|
71
|
+
end
|
72
|
+
```
|
98
73
|
|
99
|
-
|
100
|
-
|
74
|
+
In the example, `dog.treats` would still raise even though
|
75
|
+
`strict_loading` was set to false. This is a bug effecting more than
|
76
|
+
Active Storage which is why I made this PR superceeding #41461. We need
|
77
|
+
to fix this for all applications since the behavior is a little
|
78
|
+
surprising. I took the test from ##41461 and the code suggestion from #41453
|
79
|
+
with some additions.
|
101
80
|
|
102
|
-
*
|
81
|
+
*Eileen M. Uchitelle*, *Radamés Roriz*
|
103
82
|
|
104
|
-
* Fix
|
105
|
-
clone no longer show as changed attributes in the original object.
|
83
|
+
* Fix numericality validator without precision.
|
106
84
|
|
107
|
-
*
|
85
|
+
*Ryuta Kamizono*
|
108
86
|
|
109
|
-
* Fix
|
87
|
+
* Fix aggregate attribute on Enum types.
|
110
88
|
|
111
|
-
|
89
|
+
*Ryuta Kamizono*
|
112
90
|
|
113
|
-
|
91
|
+
* Fix `CREATE INDEX` statement generation for PostgreSQL.
|
114
92
|
|
115
|
-
*
|
93
|
+
*eltongo*
|
116
94
|
|
117
|
-
|
95
|
+
* Fix where clause on enum attribute when providing array of strings.
|
118
96
|
|
119
|
-
*
|
97
|
+
*Ryuta Kamizono*
|
120
98
|
|
121
|
-
*
|
122
|
-
These methods determine what relations can be used to back Active Record
|
123
|
-
models (usually tables and views).
|
99
|
+
* Fix `unprepared_statement` to work it when nesting.
|
124
100
|
|
125
|
-
*
|
101
|
+
*Ryuta Kamizono*
|
126
102
|
|
127
103
|
|
128
|
-
## Rails
|
104
|
+
## Rails 6.1.3.2 (May 05, 2021) ##
|
129
105
|
|
130
106
|
* No changes.
|
131
107
|
|
132
108
|
|
133
|
-
## Rails
|
109
|
+
## Rails 6.1.3.1 (March 26, 2021) ##
|
134
110
|
|
135
111
|
* No changes.
|
136
112
|
|
137
113
|
|
138
|
-
## Rails
|
139
|
-
|
140
|
-
* No longer pass deprecated option `-i` to `pg_dump`.
|
141
|
-
|
142
|
-
*Paul Sadauskas*
|
143
|
-
|
144
|
-
* Set `scope.reordering_value` to `true` if :reordering values are specified.
|
145
|
-
|
146
|
-
Fixes #21886.
|
147
|
-
|
148
|
-
*Hiroaki Izu*
|
149
|
-
|
150
|
-
* Avoid disabling errors on the PostgreSQL connection when enabling the
|
151
|
-
standard_conforming_strings setting. Errors were previously disabled because
|
152
|
-
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
|
153
|
-
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
|
154
|
-
setting exists. Disabling errors caused problems when using a connection
|
155
|
-
pooling tool like PgBouncer because it's not guaranteed to have the same
|
156
|
-
connection between calls to `execute` and it could leave the connection
|
157
|
-
with errors disabled.
|
158
|
-
|
159
|
-
Fixes #22101.
|
160
|
-
|
161
|
-
*Harry Marr*
|
162
|
-
|
163
|
-
* Includes HABTM returns correct size now. It's caused by the join dependency
|
164
|
-
only instantiates one HABTM object because the join table hasn't a primary key.
|
165
|
-
|
166
|
-
Fixes #16032.
|
167
|
-
|
168
|
-
Examples:
|
169
|
-
|
170
|
-
before:
|
171
|
-
|
172
|
-
Project.first.salaried_developers.size # => 3
|
173
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
174
|
-
|
175
|
-
after:
|
176
|
-
|
177
|
-
Project.first.salaried_developers.size # => 3
|
178
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
179
|
-
|
180
|
-
*Bigxiang*
|
181
|
-
|
182
|
-
* Descriptive error message when fixtures contain a missing column.
|
183
|
-
|
184
|
-
Closes #21201.
|
185
|
-
|
186
|
-
*Yves Senn*
|
114
|
+
## Rails 6.1.3 (February 17, 2021) ##
|
187
115
|
|
188
|
-
*
|
189
|
-
|
190
|
-
`Migrator.migrations_paths`.
|
191
|
-
|
192
|
-
*Tobias Bielohlawek*
|
193
|
-
|
194
|
-
* Fix `rewhere` in a `has_many` association.
|
195
|
-
|
196
|
-
Fixes #21955.
|
197
|
-
|
198
|
-
*Josh Branchaud*, *Kal*
|
199
|
-
|
200
|
-
* Added run_cmd class method to ActiveRecord::Tasks::DatabaseTasks for
|
201
|
-
drying up Kernel.system() calls within this namespace and to avoid
|
202
|
-
shell expansion by using a paramter list instead of string as arguments
|
203
|
-
for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
|
204
|
-
test units passing.
|
205
|
-
|
206
|
-
*Bryan Paxton*
|
207
|
-
|
208
|
-
* Avoid leaking the first relation we call `first` on, per model.
|
209
|
-
|
210
|
-
Fixes #21921.
|
211
|
-
|
212
|
-
*Matthew Draper*, *Jean Boussier*
|
213
|
-
|
214
|
-
* Allow deserialization of Active Record models that were YAML encoded prior
|
215
|
-
to Rails 4.2
|
216
|
-
|
217
|
-
*Sean Griffin*
|
218
|
-
|
219
|
-
* Correctly apply `unscope` when preloading through associations.
|
220
|
-
|
221
|
-
*Jimmy Bourassa*
|
222
|
-
|
223
|
-
* Ensure `select` quotes aliased attributes, even when using `from`.
|
224
|
-
|
225
|
-
Fixes #21488
|
226
|
-
|
227
|
-
*Sean Griffin & @johanlunds*
|
228
|
-
|
229
|
-
* Correct query for PostgreSQL 8.2 compatibility.
|
230
|
-
|
231
|
-
*Ben Murphy*, *Matthew Draper*
|
232
|
-
|
233
|
-
* Uniqueness validator raises descriptive error when running on a persisted
|
234
|
-
record without primary key.
|
235
|
-
|
236
|
-
Closes #21304.
|
237
|
-
|
238
|
-
*Yves Senn*
|
239
|
-
|
240
|
-
|
241
|
-
## Rails 4.2.4 (August 24, 2015) ##
|
242
|
-
|
243
|
-
* Skip statement cache on through association reader.
|
244
|
-
|
245
|
-
If the through class has default scopes we should skip the statement
|
246
|
-
cache.
|
247
|
-
|
248
|
-
Closes #20745.
|
116
|
+
* Fix the MySQL adapter to always set the right collation and charset
|
117
|
+
to the connection session.
|
249
118
|
|
250
119
|
*Rafael Mendonça França*
|
251
120
|
|
252
|
-
*
|
253
|
-
|
254
|
-
after doing a rebuild off of schema.rb.
|
255
|
-
|
256
|
-
*Jake Waller*
|
257
|
-
|
258
|
-
* Fix state being carried over from previous transaction.
|
259
|
-
|
260
|
-
Considering the following example where `name` is a required attribute.
|
261
|
-
Before we had `new_record?` returning `true` for a persisted record:
|
262
|
-
|
263
|
-
author = Author.create! name: 'foo'
|
264
|
-
author.name = nil
|
265
|
-
author.save # => false
|
266
|
-
author.new_record? # => true
|
267
|
-
|
268
|
-
Fixes #20824.
|
269
|
-
|
270
|
-
*Roque Pinel*
|
271
|
-
|
272
|
-
* Correctly ignore `mark_for_destruction` when `autosave` isn't set to `true`
|
273
|
-
when validating associations.
|
274
|
-
|
275
|
-
Fixes #20882.
|
276
|
-
|
277
|
-
*Sean Griffin*
|
278
|
-
|
279
|
-
* Fix through associations using scopes having the scope merged multiple
|
280
|
-
times.
|
281
|
-
|
282
|
-
Fixes #20721.
|
283
|
-
Fixes #20727.
|
284
|
-
|
285
|
-
*Sean Griffin*
|
286
|
-
|
287
|
-
* `ActiveRecord::Base.dump_schema_after_migration` applies migration tasks
|
288
|
-
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
289
|
-
|
290
|
-
Fixes #20743.
|
291
|
-
|
292
|
-
*Yves Senn*
|
293
|
-
|
294
|
-
* Correctly raise `ActiveRecord::AssociationTypeMismatch` when assigning
|
295
|
-
a wrong type to a namespaced association.
|
296
|
-
|
297
|
-
Fixes #20545.
|
298
|
-
|
299
|
-
*Diego Carrion*
|
121
|
+
* Fix MySQL adapter handling of time objects when prepared statements
|
122
|
+
are enabled.
|
300
123
|
|
301
|
-
*
|
302
|
-
belongs_to association.
|
303
|
-
|
304
|
-
Fixes #20426.
|
305
|
-
|
306
|
-
*James Dabbs*
|
307
|
-
|
308
|
-
|
309
|
-
## Rails 4.2.3 (June 25, 2015) ##
|
310
|
-
|
311
|
-
* Let `WITH` queries (Common Table Expressions) be explainable.
|
312
|
-
|
313
|
-
*Vladimir Kochnev*
|
314
|
-
|
315
|
-
* Fix n+1 query problem when eager loading nil associations (fixes #18312)
|
316
|
-
|
317
|
-
*Sammy Larbi*
|
318
|
-
|
319
|
-
* Fixed an error which would occur in dirty checking when calling
|
320
|
-
`update_attributes` from a getter.
|
321
|
-
|
322
|
-
Fixes #20531.
|
323
|
-
|
324
|
-
*Sean Griffin*
|
325
|
-
|
326
|
-
* Ensure symbols passed to `ActiveRecord::Relation#select` are always treated
|
327
|
-
as columns.
|
328
|
-
|
329
|
-
Fixes #20360.
|
330
|
-
|
331
|
-
*Sean Griffin*
|
332
|
-
|
333
|
-
* Clear query cache when `ActiveRecord::Base#reload` is called.
|
334
|
-
|
335
|
-
*Shane Hender*
|
336
|
-
|
337
|
-
* Pass `:extend` option for `has_and_belongs_to_many` associations to the
|
338
|
-
underlying `has_many :through`.
|
339
|
-
|
340
|
-
*Jaehyun Shin*
|
341
|
-
|
342
|
-
* Make `unscope` aware of "less than" and "greater than" conditions.
|
343
|
-
|
344
|
-
*TAKAHASHI Kazuaki*
|
345
|
-
|
346
|
-
* Revert behavior of `db:schema:load` back to loading the full
|
347
|
-
environment. This ensures that initializers are run.
|
348
|
-
|
349
|
-
Fixes #19545.
|
350
|
-
|
351
|
-
*Yves Senn*
|
124
|
+
*Rafael Mendonça França*
|
352
125
|
|
353
|
-
* Fix
|
126
|
+
* Fix scoping in enum fields using conditions that would generate
|
127
|
+
an `IN` clause.
|
354
128
|
|
355
|
-
|
356
|
-
`column` definitions for `created_at` and `updated_at` rather than just
|
357
|
-
the first.
|
129
|
+
*Ryuta Kamizono*
|
358
130
|
|
359
|
-
|
131
|
+
* Skip optimised #exist? query when #include? is called on a relation
|
132
|
+
with a having clause
|
360
133
|
|
361
|
-
|
134
|
+
Relations that have aliased select values AND a having clause that
|
135
|
+
references an aliased select value would generate an error when
|
136
|
+
#include? was called, due to an optimisation that would generate
|
137
|
+
call #exists? on the relation instead, which effectively alters
|
138
|
+
the select values of the query (and thus removes the aliased select
|
139
|
+
values), but leaves the having clause intact. Because the having
|
140
|
+
clause is then referencing an aliased column that is no longer
|
141
|
+
present in the simplified query, an ActiveRecord::InvalidStatement
|
142
|
+
error was raised.
|
362
143
|
|
363
|
-
|
144
|
+
An sample query affected by this problem:
|
364
145
|
|
365
|
-
|
146
|
+
```ruby
|
147
|
+
Author.select('COUNT(*) as total_posts', 'authors.*')
|
148
|
+
.joins(:posts)
|
149
|
+
.group(:id)
|
150
|
+
.having('total_posts > 2')
|
151
|
+
.include?(Author.first)
|
152
|
+
```
|
366
153
|
|
367
|
-
|
368
|
-
|
154
|
+
This change adds an addition check to the condition that skips the
|
155
|
+
simplified #exists? query, which simply checks for the presence of
|
156
|
+
a having clause.
|
369
157
|
|
370
|
-
|
158
|
+
Fixes #41417
|
371
159
|
|
372
|
-
*
|
373
|
-
`ActiveRecord::Base.pluralize_table_names = false`.
|
160
|
+
*Michael Smart*
|
374
161
|
|
375
|
-
|
162
|
+
* Increment postgres prepared statement counter before making a prepared statement, so if the statement is aborted
|
163
|
+
without Rails knowledge (e.g., if app gets kill -9d during long-running query or due to Rack::Timeout), app won't end
|
164
|
+
up in perpetual crash state for being inconsistent with Postgres.
|
376
165
|
|
377
|
-
*
|
166
|
+
*wbharding*, *Martin Tepper*
|
378
167
|
|
379
|
-
* Reduce memory usage from loading types on pg.
|
380
168
|
|
381
|
-
|
169
|
+
## Rails 6.1.2.1 (February 10, 2021) ##
|
382
170
|
|
383
|
-
|
171
|
+
* Fix possible DoS vector in PostgreSQL money type
|
384
172
|
|
385
|
-
|
386
|
-
|
173
|
+
Carefully crafted input can cause a DoS via the regular expressions used
|
174
|
+
for validating the money format in the PostgreSQL adapter. This patch
|
175
|
+
fixes the regexp.
|
387
176
|
|
388
|
-
|
177
|
+
Thanks to @dee-see from Hackerone for this patch!
|
389
178
|
|
390
|
-
|
179
|
+
[CVE-2021-22880]
|
391
180
|
|
392
|
-
*
|
181
|
+
*Aaron Patterson*
|
393
182
|
|
394
|
-
Fixes #19437.
|
395
183
|
|
396
|
-
|
184
|
+
## Rails 6.1.2 (February 09, 2021) ##
|
397
185
|
|
398
|
-
*
|
399
|
-
its default value by an in-place modification.
|
186
|
+
* Fix timestamp type for sqlite3.
|
400
187
|
|
401
|
-
|
188
|
+
*Eileen M. Uchitelle*
|
402
189
|
|
403
|
-
|
190
|
+
* Make destroy async transactional.
|
404
191
|
|
405
|
-
|
192
|
+
An active record rollback could occur while enqueuing a job. In this
|
193
|
+
case the job would enqueue even though the database deletion
|
194
|
+
rolledback putting things in a funky state.
|
406
195
|
|
407
|
-
|
196
|
+
Now the jobs are only enqueued until after the db transaction has been committed.
|
408
197
|
|
409
|
-
*
|
410
|
-
That was causing a memory grow problem when creating a lot of records inside a transaction.
|
198
|
+
*Cory Gwin*
|
411
199
|
|
412
|
-
|
200
|
+
* Fix malformed packet error in MySQL statement for connection configuration.
|
413
201
|
|
414
|
-
*
|
202
|
+
*robinroestenburg*
|
415
203
|
|
416
|
-
*
|
417
|
-
|
204
|
+
* Connection specification now passes the "url" key as a configuration for the
|
205
|
+
adapter if the "url" protocol is "jdbc", "http", or "https". Previously only
|
206
|
+
urls with the "jdbc" prefix were passed to the Active Record Adapter, others
|
207
|
+
are assumed to be adapter specification urls.
|
418
208
|
|
419
|
-
Fixes #
|
209
|
+
Fixes #41137.
|
420
210
|
|
421
|
-
*
|
211
|
+
*Jonathan Bracy*
|
422
212
|
|
213
|
+
* Fix granular connection swapping when there are multiple abstract classes.
|
423
214
|
|
424
|
-
|
215
|
+
*Eileen M. Uchitelle*
|
425
216
|
|
426
|
-
*
|
217
|
+
* Fix `find_by` with custom primary key for belongs_to association.
|
427
218
|
|
219
|
+
*Ryuta Kamizono*
|
428
220
|
|
429
|
-
|
221
|
+
* Add support for `rails console --sandbox` for multiple database applications.
|
430
222
|
|
431
|
-
*
|
223
|
+
*alpaca-tc*
|
432
224
|
|
433
|
-
|
225
|
+
* Fix `where` on polymorphic association with empty array.
|
434
226
|
|
435
|
-
*
|
227
|
+
*Ryuta Kamizono*
|
436
228
|
|
437
|
-
*
|
438
|
-
removing the column. This fixes a bug where it was not possible to remove
|
439
|
-
the column on MySQL.
|
229
|
+
* Fix preventing writes for `ApplicationRecord`.
|
440
230
|
|
441
|
-
|
231
|
+
*Eileen M. Uchitelle*
|
442
232
|
|
443
|
-
*Yves Senn*
|
444
233
|
|
445
|
-
|
446
|
-
methods. The model and migration generators now use this option, rather than
|
447
|
-
the `add_foreign_key` form.
|
234
|
+
## Rails 6.1.1 (January 07, 2021) ##
|
448
235
|
|
449
|
-
|
236
|
+
* Fix fixtures loading when strict loading is enabled for the association.
|
450
237
|
|
451
|
-
*
|
238
|
+
*Alex Ghiculescu*
|
452
239
|
|
453
|
-
|
454
|
-
the precision of timestamp column.
|
240
|
+
* Fix `where` with custom primary key for belongs_to association.
|
455
241
|
|
456
242
|
*Ryuta Kamizono*
|
457
243
|
|
458
|
-
*
|
459
|
-
|
460
|
-
The charset of `version` column in `schema_migrations` table is depend
|
461
|
-
on the database default charset and collation rather than the encoding
|
462
|
-
of the connection.
|
244
|
+
* Fix `where` with aliased associations.
|
463
245
|
|
464
246
|
*Ryuta Kamizono*
|
465
247
|
|
466
|
-
*
|
467
|
-
|
468
|
-
Fixes #18813.
|
469
|
-
|
470
|
-
*Sean Griffin*
|
471
|
-
|
472
|
-
* Fixed several edge cases which could result in a counter cache updating
|
473
|
-
twice or not updating at all for `has_many` and `has_many :through`.
|
474
|
-
|
475
|
-
Fixes #10865.
|
476
|
-
|
477
|
-
*Sean Griffin*
|
478
|
-
|
479
|
-
* Foreign keys added by migrations were given random, generated names. This
|
480
|
-
meant a different `structure.sql` would be generated every time a developer
|
481
|
-
ran migrations on their machine.
|
482
|
-
|
483
|
-
The generated part of foreign key names is now a hash of the table name and
|
484
|
-
column name, which is consistent every time you run the migration.
|
485
|
-
|
486
|
-
*Chris Sinjakli*
|
487
|
-
|
488
|
-
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
489
|
-
|
490
|
-
SplitTest.group(:key).count
|
491
|
-
Property.group(:value).count
|
492
|
-
|
493
|
-
*Bogdan Gusiev*
|
494
|
-
|
495
|
-
* Don't define autosave association callbacks twice from
|
496
|
-
`accepts_nested_attributes_for`.
|
497
|
-
|
498
|
-
Fixes #18704.
|
499
|
-
|
500
|
-
*Sean Griffin*
|
501
|
-
|
502
|
-
* Integer types will no longer raise a `RangeError` when assigning an
|
503
|
-
attribute, but will instead raise when going to the database.
|
504
|
-
|
505
|
-
Fixes several vague issues which were never reported directly. See the
|
506
|
-
commit message from the commit which added this line for some examples.
|
507
|
-
|
508
|
-
*Sean Griffin*
|
509
|
-
|
510
|
-
* Values which would error while being sent to the database (such as an
|
511
|
-
ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
|
512
|
-
assignment. They will still error when sent to the database, but you are
|
513
|
-
given the ability to re-assign it to a valid value.
|
514
|
-
|
515
|
-
Fixes #18580.
|
516
|
-
|
517
|
-
*Sean Griffin*
|
518
|
-
|
519
|
-
* Don't remove join dependencies in `Relation#exists?`
|
520
|
-
|
521
|
-
Fixes #18632.
|
522
|
-
|
523
|
-
*Sean Griffin*
|
524
|
-
|
525
|
-
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
526
|
-
|
527
|
-
Fixes #18629.
|
528
|
-
|
529
|
-
*Sean Griffin*
|
530
|
-
|
531
|
-
* No longer issue deprecation warning when including a scope with extensions.
|
532
|
-
Previously every scope with extension methods was transformed into an
|
533
|
-
instance dependent scope. Including such a scope would wrongfully issue a
|
534
|
-
deprecation warning. This is no longer the case.
|
535
|
-
|
536
|
-
Fixes #18467.
|
537
|
-
|
538
|
-
*Yves Senn*
|
539
|
-
|
540
|
-
* Correctly use the type provided by `serialize` when updating records using
|
541
|
-
optimistic locking.
|
542
|
-
|
543
|
-
Fixes #18385.
|
544
|
-
|
545
|
-
*Sean Griffin*
|
546
|
-
|
547
|
-
* `attribute_will_change!` will no longer cause non-persistable attributes to
|
548
|
-
be sent to the database.
|
549
|
-
|
550
|
-
Fixes #18407.
|
551
|
-
|
552
|
-
*Sean Griffin*
|
553
|
-
|
554
|
-
* Format the datetime string according to the precision of the datetime field.
|
555
|
-
|
556
|
-
Incompatible to rounding behavior between MySQL 5.6 and earlier.
|
557
|
-
|
558
|
-
In 5.5, when you insert `2014-08-17 12:30:00.999999` the fractional part
|
559
|
-
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
560
|
-
|
561
|
-
http://bugs.mysql.com/bug.php?id=68760
|
248
|
+
* Fix `composed_of` with symbol mapping.
|
562
249
|
|
563
250
|
*Ryuta Kamizono*
|
564
251
|
|
565
|
-
*
|
252
|
+
* Don't skip money's type cast for pluck and calculations.
|
566
253
|
|
567
254
|
*Ryuta Kamizono*
|
568
255
|
|
569
|
-
*
|
570
|
-
|
571
|
-
*Florian Weingarten*
|
572
|
-
|
573
|
-
* Fixed setting of foreign_key for through associations while building of new record.
|
574
|
-
|
575
|
-
Fixes #12698.
|
576
|
-
|
577
|
-
*Ivan Antropov*
|
578
|
-
|
579
|
-
* Fixed automatic inverse_of for models nested in module.
|
580
|
-
|
581
|
-
*Andrew McCloud*
|
582
|
-
|
583
|
-
* Fix `reaping_frequency` option when the value is a string.
|
584
|
-
|
585
|
-
This usually happens when it is configured using `DATABASE_URL`.
|
586
|
-
|
587
|
-
*korbin*
|
588
|
-
|
589
|
-
* Fix error message when trying to create an associated record and the foreign
|
590
|
-
key is missing.
|
591
|
-
|
592
|
-
Before this fix the following exception was being raised:
|
593
|
-
|
594
|
-
NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
|
595
|
-
|
596
|
-
Now the message is:
|
597
|
-
|
598
|
-
ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
|
599
|
-
|
600
|
-
*Rafael Mendonça França*
|
601
|
-
|
602
|
-
* Fix change detection problem for PostgreSQL bytea type and
|
603
|
-
`ArgumentError: string contains null byte` exception with pg-0.18.
|
604
|
-
|
605
|
-
Fixes #17680.
|
606
|
-
|
607
|
-
*Lars Kanis*
|
608
|
-
|
609
|
-
* When a table has a composite primary key, the `primary_key` method for
|
610
|
-
SQLite3 and PostgreSQL adapters was only returning the first field of the key.
|
611
|
-
Ensures that it will return nil instead, as Active Record doesn't support
|
612
|
-
composite primary keys.
|
613
|
-
|
614
|
-
Fixes #18070.
|
615
|
-
|
616
|
-
*arthurnn*
|
617
|
-
|
618
|
-
* Ensure `first!` and friends work on loaded associations.
|
619
|
-
|
620
|
-
Fixes #18237.
|
621
|
-
|
622
|
-
*Sean Griffin*
|
623
|
-
|
624
|
-
* Dump the default `nil` for PostgreSQL UUID primary key.
|
256
|
+
* Fix `where` on polymorphic association with non Active Record object.
|
625
257
|
|
626
258
|
*Ryuta Kamizono*
|
627
259
|
|
628
|
-
*
|
629
|
-
by the user.
|
630
|
-
|
631
|
-
*Grey Baker*
|
632
|
-
|
633
|
-
* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
|
634
|
-
be marked as having changed when set to the same negative value.
|
635
|
-
|
636
|
-
Fixes #18161.
|
637
|
-
|
638
|
-
*Daniel Fox*
|
639
|
-
|
260
|
+
* Make sure `db:prepare` works even the schema file doesn't exist.
|
640
261
|
|
641
|
-
|
642
|
-
|
643
|
-
* Introduce `force: :cascade` option for `create_table`. Using this option
|
644
|
-
will recreate tables even if they have dependent objects (like foreign keys).
|
645
|
-
`db/schema.rb` now uses `force: :cascade`. This makes it possible to
|
646
|
-
reload the schema when foreign keys are in place.
|
647
|
-
|
648
|
-
*Matthew Draper*, *Yves Senn*
|
649
|
-
|
650
|
-
* `db:schema:load` and `db:structure:load` no longer purge the database
|
651
|
-
before loading the schema. This is left for the user to do.
|
652
|
-
`db:test:prepare` will still purge the database.
|
653
|
-
|
654
|
-
Fixes #17945.
|
655
|
-
|
656
|
-
*Yves Senn*
|
262
|
+
*Rafael Mendonça França*
|
657
263
|
|
658
|
-
* Fix
|
264
|
+
* Fix complicated `has_many :through` with nested where condition.
|
659
265
|
|
660
266
|
*Ryuta Kamizono*
|
661
267
|
|
662
|
-
*
|
663
|
-
|
664
|
-
This option enables to define the column name of associated object's type for polymorphic associations.
|
665
|
-
|
666
|
-
*Ulisses Almeida, Kassio Borges*
|
667
|
-
|
668
|
-
* `add_timestamps` and `remove_timestamps` now properly reversible with
|
669
|
-
options.
|
670
|
-
|
671
|
-
*Noam Gagliardi-Rabinovich*
|
672
|
-
|
673
|
-
* Bring back `db:test:prepare` to synchronize the test database schema.
|
674
|
-
|
675
|
-
Manual synchronization using `bin/rake db:test:prepare` is required
|
676
|
-
when a migration is rolled-back, edited and reapplied.
|
677
|
-
|
678
|
-
`ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
|
679
|
-
to synchronize the schema. Plugins can use this task as a hook to
|
680
|
-
provide custom behavior after the schema has been loaded.
|
681
|
-
|
682
|
-
NOTE: `test:prepare` runs before the schema is synchronized.
|
683
|
-
|
684
|
-
Fixes #17171, #15787.
|
685
|
-
|
686
|
-
*Yves Senn*
|
687
|
-
|
688
|
-
* Change `reflections` public api to return the keys as String objects.
|
689
|
-
|
690
|
-
Fixes #16928.
|
691
|
-
|
692
|
-
*arthurnn*
|
693
|
-
|
694
|
-
* Renaming a table in pg also renames the primary key index.
|
695
|
-
|
696
|
-
Fixes #12856
|
697
|
-
|
698
|
-
*Sean Griffin*
|
699
|
-
|
700
|
-
* Make it possible to access fixtures excluded by a `default_scope`.
|
701
|
-
|
702
|
-
*Yves Senn*
|
703
|
-
|
704
|
-
* Fix preloading of associations with a scope containing joins along with
|
705
|
-
conditions on the joined association.
|
706
|
-
|
707
|
-
*Siddharth Sharma*
|
708
|
-
|
709
|
-
* Add `Table#name` to match `TableDefinition#name`.
|
710
|
-
|
711
|
-
*Cody Cutrer*
|
712
|
-
|
713
|
-
* Cache `CollectionAssociation#reader` proxies separately before and after
|
714
|
-
the owner has been saved so that the proxy is not cached without the
|
715
|
-
owner's id.
|
716
|
-
|
717
|
-
*Ben Woosley*
|
718
|
-
|
719
|
-
* `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
|
720
|
-
|
721
|
-
*Franky W.*
|
722
|
-
|
723
|
-
* Fix preloading of associations which unscope a default scope.
|
268
|
+
* Handle STI models for `has_many dependent: :destroy_async`.
|
724
269
|
|
725
|
-
|
270
|
+
*Muhammad Usman*
|
726
271
|
|
727
|
-
|
272
|
+
* Restore possibility of passing `false` to :polymorphic option of `belongs_to`.
|
728
273
|
|
729
|
-
|
274
|
+
Previously, passing `false` would trigger the option validation logic
|
275
|
+
to throw an error saying :polymorphic would not be a valid option.
|
730
276
|
|
731
|
-
*
|
277
|
+
*glaszig*
|
732
278
|
|
733
|
-
*
|
734
|
-
`Relation` for performing queries and updates is the prefered API.
|
279
|
+
* Allow adding nonnamed expression indexes to be revertible.
|
735
280
|
|
736
|
-
|
281
|
+
Fixes #40732.
|
737
282
|
|
738
|
-
|
739
|
-
|
283
|
+
Previously, the following code would raise an error, when executed while rolling back,
|
284
|
+
and the index name should be specified explicitly. Now, the index name is inferred
|
285
|
+
automatically.
|
740
286
|
|
741
|
-
|
287
|
+
```ruby
|
288
|
+
add_index(:items, "to_tsvector('english', description)")
|
289
|
+
```
|
742
290
|
|
743
|
-
*
|
744
|
-
in an endless loop.
|
291
|
+
*fatkodima*
|
745
292
|
|
746
|
-
Fixes #17402.
|
747
293
|
|
748
|
-
|
294
|
+
## Rails 6.1.0 (December 09, 2020) ##
|
749
295
|
|
750
|
-
*
|
296
|
+
* Only warn about negative enums if a positive form that would cause conflicts exists.
|
751
297
|
|
752
|
-
|
298
|
+
Fixes #39065.
|
753
299
|
|
754
|
-
*
|
300
|
+
*Alex Ghiculescu*
|
755
301
|
|
756
|
-
|
302
|
+
* Change `attribute_for_inspect` to take `filter_attributes` in consideration.
|
757
303
|
|
758
|
-
*
|
759
|
-
|
760
|
-
*Dan Olson*
|
761
|
-
|
762
|
-
* `AR::UnknownAttributeError` now includes the class name of a record.
|
763
|
-
|
764
|
-
User.new(name: "Yuki Nishijima", project_attributes: {name: "kaminari"})
|
765
|
-
# => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
|
766
|
-
|
767
|
-
*Yuki Nishijima*
|
768
|
-
|
769
|
-
* Fix a regression causing `after_create` callbacks to run before associated
|
770
|
-
records are autosaved.
|
771
|
-
|
772
|
-
Fixes #17209.
|
773
|
-
|
774
|
-
*Agis Anastasopoulos*
|
775
|
-
|
776
|
-
* Honor overridden `rack.test` in Rack environment for the connection
|
777
|
-
management middleware.
|
778
|
-
|
779
|
-
*Simon Eskildsen*
|
780
|
-
|
781
|
-
* Add a truncate method to the connection.
|
782
|
-
|
783
|
-
*Aaron Patterson*
|
784
|
-
|
785
|
-
* Don't autosave unchanged has_one through records.
|
786
|
-
|
787
|
-
*Alan Kennedy*, *Steve Parrington*
|
788
|
-
|
789
|
-
* Do not dump foreign keys for ignored tables.
|
790
|
-
|
791
|
-
*Yves Senn*
|
304
|
+
*Rafael Mendonça França*
|
792
305
|
|
793
|
-
*
|
794
|
-
outside the schema search path.
|
306
|
+
* Fix odd behavior of inverse_of with multiple belongs_to to same class.
|
795
307
|
|
796
|
-
Fixes #
|
308
|
+
Fixes #35204.
|
797
309
|
|
798
|
-
*
|
310
|
+
*Tomoyuki Kai*
|
799
311
|
|
800
|
-
*
|
801
|
-
committing it during the stack unwind. Previously, we could commit half-
|
802
|
-
completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
|
803
|
-
distinguish a thread kill from an ordinary non-local (block) return, so must
|
804
|
-
default to committing.
|
312
|
+
* Build predicate conditions with objects that delegate `#id` and primary key:
|
805
313
|
|
806
|
-
|
314
|
+
```ruby
|
315
|
+
class AdminAuthor
|
316
|
+
delegate_missing_to :@author
|
807
317
|
|
808
|
-
|
809
|
-
|
318
|
+
def initialize(author)
|
319
|
+
@author = author
|
320
|
+
end
|
321
|
+
end
|
810
322
|
|
811
|
-
|
323
|
+
Post.where(author: AdminAuthor.new(author))
|
324
|
+
```
|
812
325
|
|
813
|
-
*
|
326
|
+
*Sean Doyle*
|
814
327
|
|
815
|
-
*
|
816
|
-
in the future without affecting old migrations that assumed old defaults.
|
328
|
+
* Add `connected_to_many` API.
|
817
329
|
|
818
|
-
|
330
|
+
This API allows applications to connect to multiple databases at once without switching all of them or implementing a deeply nested stack.
|
819
331
|
|
820
|
-
|
332
|
+
Before:
|
821
333
|
|
822
|
-
|
334
|
+
AnimalsRecord.connected_to(role: :reading) do
|
335
|
+
MealsRecord.connected_to(role: :reading) do
|
336
|
+
Dog.first # read from animals replica
|
337
|
+
Dinner.first # read from meals replica
|
338
|
+
Person.first # read from primary writer
|
339
|
+
end
|
340
|
+
end
|
823
341
|
|
824
|
-
|
342
|
+
After:
|
825
343
|
|
826
|
-
|
344
|
+
ActiveRecord::Base.connected_to_many([AnimalsRecord, MealsRecord], role: :reading) do
|
345
|
+
Dog.first # read from animals replica
|
346
|
+
Dinner.first # read from meals replica
|
347
|
+
Person.first # read from primary writer
|
348
|
+
end
|
827
349
|
|
828
|
-
*
|
350
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
829
351
|
|
830
|
-
|
352
|
+
* Add option to raise or log for `ActiveRecord::StrictLoadingViolationError`.
|
831
353
|
|
832
|
-
|
833
|
-
has support for SQL views. Connection adapters should define this method.
|
354
|
+
Some applications may not want to raise an error in production if using `strict_loading`. This would allow an application to set strict loading to log for the production environment while still raising in development and test environments.
|
834
355
|
|
835
|
-
|
356
|
+
Set `config.active_record.action_on_strict_loading_violation` to `:log` errors instead of raising.
|
836
357
|
|
837
|
-
*
|
358
|
+
*Eileen M. Uchitelle*
|
838
359
|
|
839
|
-
|
360
|
+
* Allow the inverse of a `has_one` association that was previously autosaved to be loaded.
|
840
361
|
|
841
|
-
|
362
|
+
Fixes #34255.
|
842
363
|
|
843
|
-
*
|
844
|
-
the database connection to the current environment.
|
364
|
+
*Steven Weber*
|
845
365
|
|
846
|
-
|
366
|
+
* Optimise the length of index names for polymorphic references by using the reference name rather than the type and id column names.
|
847
367
|
|
848
|
-
|
368
|
+
Because the default behaviour when adding an index with multiple columns is to use all column names in the index name, this could frequently lead to overly long index names for polymorphic references which would fail the migration if it exceeded the database limit.
|
849
369
|
|
850
|
-
|
370
|
+
This change reduces the chance of that happening by using the reference name, e.g. `index_my_table_on_my_reference`.
|
851
371
|
|
852
|
-
|
853
|
-
database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
|
854
|
-
collation for that charset (utf8mb4_general_ci) when you may have chosen
|
855
|
-
a different collation, like utf8mb4_unicode_ci.
|
372
|
+
Fixes #38655.
|
856
373
|
|
857
|
-
|
858
|
-
is unlikely to affect you.
|
374
|
+
*Luke Redpath*
|
859
375
|
|
860
|
-
|
376
|
+
* MySQL: Uniqueness validator now respects default database collation,
|
377
|
+
no longer enforce case sensitive comparison by default.
|
861
378
|
|
862
|
-
*
|
379
|
+
*Ryuta Kamizono*
|
863
380
|
|
864
|
-
|
381
|
+
* Remove deprecated methods from `ActiveRecord::ConnectionAdapters::DatabaseLimits`.
|
865
382
|
|
866
|
-
|
867
|
-
|
383
|
+
`column_name_length`
|
384
|
+
`table_name_length`
|
385
|
+
`columns_per_table`
|
386
|
+
`indexes_per_table`
|
387
|
+
`columns_per_multicolumn_index`
|
388
|
+
`sql_query_length`
|
389
|
+
`joins_per_query`
|
868
390
|
|
869
|
-
*
|
391
|
+
*Rafael Mendonça França*
|
870
392
|
|
871
|
-
|
393
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert?`.
|
872
394
|
|
873
|
-
*
|
874
|
-
passed as a lambda with an arity of one.
|
395
|
+
*Rafael Mendonça França*
|
875
396
|
|
876
|
-
|
397
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create?`.
|
877
398
|
|
878
|
-
*
|
399
|
+
*Rafael Mendonça França*
|
879
400
|
|
880
|
-
*
|
401
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges?`.
|
881
402
|
|
882
|
-
|
403
|
+
*Rafael Mendonça França*
|
883
404
|
|
884
|
-
|
405
|
+
* Remove deprecated `ActiveRecord::Base#update_attributes` and `ActiveRecord::Base#update_attributes!`.
|
885
406
|
|
886
|
-
*
|
887
|
-
`after_rollback`/`after_create` callbacks and prints them to the logs.
|
888
|
-
Future versions of Rails will not rescue these errors anymore and
|
889
|
-
just bubble them up like the other callbacks.
|
407
|
+
*Rafael Mendonça França*
|
890
408
|
|
891
|
-
|
409
|
+
* Remove deprecated `migrations_path` argument in `ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_version`.
|
892
410
|
|
893
|
-
|
411
|
+
*Rafael Mendonça França*
|
894
412
|
|
895
|
-
|
896
|
-
config.active_record.raise_in_transactional_callbacks = true
|
413
|
+
* Remove deprecated `config.active_record.sqlite3.represent_boolean_as_integer`.
|
897
414
|
|
898
|
-
|
415
|
+
*Rafael Mendonça França*
|
899
416
|
|
900
|
-
|
417
|
+
* `relation.create` does no longer leak scope to class level querying methods
|
418
|
+
in initialization block and callbacks.
|
901
419
|
|
902
|
-
|
903
|
-
`enum`) with the same name as a global method are incorrectly overridden
|
904
|
-
when subclassing.
|
420
|
+
Before:
|
905
421
|
|
906
|
-
|
422
|
+
User.where(name: "John").create do |john|
|
423
|
+
User.find_by(name: "David") # => nil
|
424
|
+
end
|
907
425
|
|
908
|
-
|
426
|
+
After:
|
909
427
|
|
910
|
-
|
911
|
-
|
428
|
+
User.where(name: "John").create do |john|
|
429
|
+
User.find_by(name: "David") # => #<User name: "David", ...>
|
430
|
+
end
|
912
431
|
|
913
|
-
*
|
432
|
+
*Ryuta Kamizono*
|
914
433
|
|
915
|
-
*
|
434
|
+
* Named scope chain does no longer leak scope to class level querying methods.
|
916
435
|
|
917
|
-
|
436
|
+
class User < ActiveRecord::Base
|
437
|
+
scope :david, -> { User.where(name: "David") }
|
438
|
+
end
|
918
439
|
|
919
|
-
|
440
|
+
Before:
|
920
441
|
|
921
|
-
|
442
|
+
User.where(name: "John").david
|
443
|
+
# SELECT * FROM users WHERE name = 'John' AND name = 'David'
|
922
444
|
|
923
|
-
|
445
|
+
After:
|
924
446
|
|
925
|
-
|
447
|
+
User.where(name: "John").david
|
448
|
+
# SELECT * FROM users WHERE name = 'David'
|
926
449
|
|
927
|
-
*
|
450
|
+
*Ryuta Kamizono*
|
928
451
|
|
929
|
-
|
452
|
+
* Remove deprecated methods from `ActiveRecord::DatabaseConfigurations`.
|
930
453
|
|
931
|
-
|
454
|
+
`fetch`
|
455
|
+
`each`
|
456
|
+
`first`
|
457
|
+
`values`
|
458
|
+
`[]=`
|
932
459
|
|
933
|
-
|
934
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
935
|
-
index_exists? :articles, :body, name: "idx_title" # => `true`
|
460
|
+
*Rafael Mendonça França*
|
936
461
|
|
937
|
-
|
938
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
939
|
-
index_exists? :articles, :body, name: "idx_title" # => `false`
|
462
|
+
* `where.not` now generates NAND predicates instead of NOR.
|
940
463
|
|
941
|
-
|
464
|
+
Before:
|
942
465
|
|
943
|
-
|
944
|
-
|
945
|
-
With Rails 5 this will change to `null: false`.
|
466
|
+
User.where.not(name: "Jon", role: "admin")
|
467
|
+
# SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
|
946
468
|
|
947
|
-
|
469
|
+
After:
|
948
470
|
|
949
|
-
|
950
|
-
|
951
|
-
destroyed.
|
471
|
+
User.where.not(name: "Jon", role: "admin")
|
472
|
+
# SELECT * FROM users WHERE NOT (name == 'Jon' AND role == 'admin')
|
952
473
|
|
953
|
-
*
|
474
|
+
*Rafael Mendonça França*
|
954
475
|
|
955
|
-
*
|
476
|
+
* Remove deprecated `ActiveRecord::Result#to_hash` method.
|
956
477
|
|
957
|
-
|
958
|
-
Active Record will return the current value of the primary key. This
|
959
|
-
makes it impossible to correctly do an update operation if you change the
|
960
|
-
id.
|
478
|
+
*Rafael Mendonça França*
|
961
479
|
|
962
|
-
|
480
|
+
* Deprecate `ActiveRecord::Base.allow_unsafe_raw_sql`.
|
963
481
|
|
964
482
|
*Rafael Mendonça França*
|
965
483
|
|
966
|
-
*
|
967
|
-
Use `.load_schema_current` instead. In the future `load_schema` will
|
968
|
-
require the `configuration` to act on as an argument.
|
484
|
+
* Remove deprecated support for using unsafe raw SQL in `ActiveRecord::Relation` methods.
|
969
485
|
|
970
|
-
*
|
971
|
-
|
972
|
-
* Fix automatic maintaining test schema to properly handle sql structure
|
973
|
-
schema format.
|
486
|
+
*Rafael Mendonça França*
|
974
487
|
|
975
|
-
|
488
|
+
* Allow users to silence the "Rails couldn't infer whether you are using multiple databases..."
|
489
|
+
message using `config.active_record.suppress_multiple_database_warning`.
|
976
490
|
|
977
|
-
*
|
491
|
+
*Omri Gabay*
|
978
492
|
|
979
|
-
*
|
493
|
+
* Connections can be granularly switched for abstract classes when `connected_to` is called.
|
980
494
|
|
981
|
-
|
495
|
+
This change allows `connected_to` to switch a `role` and/or `shard` for a single abstract class instead of all classes globally. Applications that want to use the new feature need to set `config.active_record.legacy_connection_handling` to `false` in their application configuration.
|
982
496
|
|
983
|
-
|
497
|
+
Example usage:
|
984
498
|
|
985
|
-
`
|
986
|
-
source so it has been deprecated. Code that used `source_macro`
|
987
|
-
was removed in #16353.
|
499
|
+
Given an application we have a `User` model that inherits from `ApplicationRecord` and a `Dog` model that inherits from `AnimalsRecord`. `AnimalsRecord` and `ApplicationRecord` have writing and reading connections as well as shard `default`, `one`, and `two`.
|
988
500
|
|
989
|
-
|
501
|
+
```ruby
|
502
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
503
|
+
User.first # reads from default replica
|
504
|
+
Dog.first # reads from default replica
|
990
505
|
|
991
|
-
|
506
|
+
AnimalsRecord.connected_to(role: :writing, shard: :one) do
|
507
|
+
User.first # reads from default replica
|
508
|
+
Dog.first # reads from shard one primary
|
509
|
+
end
|
992
510
|
|
993
|
-
|
511
|
+
User.first # reads from default replica
|
512
|
+
Dog.first # reads from default replica
|
994
513
|
|
995
|
-
|
514
|
+
ApplicationRecord.connected_to(role: :writing, shard: :two) do
|
515
|
+
User.first # reads from shard two primary
|
516
|
+
Dog.first # reads from default replica
|
517
|
+
end
|
518
|
+
end
|
519
|
+
```
|
996
520
|
|
997
|
-
*
|
521
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
998
522
|
|
999
|
-
|
523
|
+
* Allow double-dash comment syntax when querying read-only databases
|
1000
524
|
|
1001
|
-
|
1002
|
-
t.jsonb :meta_data
|
1003
|
-
end
|
525
|
+
*James Adam*
|
1004
526
|
|
1005
|
-
|
527
|
+
* Add `values_at` method.
|
1006
528
|
|
1007
|
-
|
529
|
+
Returns an array containing the values associated with the given methods.
|
1008
530
|
|
1009
|
-
|
531
|
+
```ruby
|
532
|
+
topic = Topic.first
|
533
|
+
topic.values_at(:title, :author_name)
|
534
|
+
# => ["Budget", "Jason"]
|
535
|
+
```
|
1010
536
|
|
1011
|
-
|
1012
|
-
`DROP DEFAULT` instead of a `DEFAULT NULL` query.
|
537
|
+
Similar to `Hash#values_at` but on an Active Record instance.
|
1013
538
|
|
1014
|
-
|
539
|
+
*Guillaume Briday*
|
1015
540
|
|
1016
|
-
|
541
|
+
* Fix `read_attribute_before_type_cast` to consider attribute aliases.
|
1017
542
|
|
1018
|
-
*
|
1019
|
-
and `add_reference`.
|
543
|
+
*Marcelo Lauxen*
|
1020
544
|
|
1021
|
-
|
545
|
+
* Support passing record to uniqueness validator `:conditions` callable:
|
1022
546
|
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
547
|
+
```ruby
|
548
|
+
class Article < ApplicationRecord
|
549
|
+
validates_uniqueness_of :title, conditions: ->(article) {
|
550
|
+
published_at = article.published_at
|
551
|
+
where(published_at: published_at.beginning_of_year..published_at.end_of_year)
|
552
|
+
}
|
553
|
+
end
|
554
|
+
```
|
1026
555
|
|
1027
|
-
*
|
556
|
+
*Eliot Sykes*
|
1028
557
|
|
1029
|
-
* `
|
1030
|
-
|
558
|
+
* `BatchEnumerator#update_all` and `BatchEnumerator#delete_all` now return the
|
559
|
+
total number of rows affected, just like their non-batched counterparts.
|
1031
560
|
|
1032
|
-
|
561
|
+
```ruby
|
562
|
+
Person.in_batches.update_all("first_name = 'Eugene'") # => 42
|
563
|
+
Person.in_batches.delete_all # => 42
|
564
|
+
```
|
1033
565
|
|
1034
|
-
|
566
|
+
Fixes #40287.
|
1035
567
|
|
1036
|
-
*
|
1037
|
-
a class.
|
568
|
+
*Eugene Kenny*
|
1038
569
|
|
1039
|
-
|
570
|
+
* Add support for PostgreSQL `interval` data type with conversion to
|
571
|
+
`ActiveSupport::Duration` when loading records from database and
|
572
|
+
serialization to ISO 8601 formatted duration string on save.
|
573
|
+
Add support to define a column in migrations and get it in a schema dump.
|
574
|
+
Optional column precision is supported.
|
1040
575
|
|
1041
|
-
|
576
|
+
To use this in 6.1, you need to place the next string to your model file:
|
1042
577
|
|
1043
|
-
|
578
|
+
attribute :duration, :interval
|
1044
579
|
|
1045
|
-
|
580
|
+
To keep old behavior until 6.2 is released:
|
1046
581
|
|
1047
|
-
|
1048
|
-
the second attribute. It will now return a hash as per previous versions.
|
582
|
+
attribute :duration, :string
|
1049
583
|
|
1050
584
|
Example:
|
1051
585
|
|
1052
|
-
|
1053
|
-
|
586
|
+
create_table :events do |t|
|
587
|
+
t.string :name
|
588
|
+
t.interval :duration
|
1054
589
|
end
|
1055
590
|
|
1056
|
-
class
|
1057
|
-
|
1058
|
-
attr_accessor :category, :text
|
591
|
+
class Event < ApplicationRecord
|
592
|
+
attribute :duration, :interval
|
1059
593
|
end
|
1060
594
|
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
#
|
1066
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1067
|
-
|
1068
|
-
# 4.1 before
|
1069
|
-
post.comment # => "#<Comment:0x007f80ab48ff98>"
|
1070
|
-
|
1071
|
-
# 4.1 after
|
1072
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1073
|
-
|
1074
|
-
When using `JSON` as the coder in `serialize`, Active Record will use the
|
1075
|
-
new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
|
1076
|
-
`ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
|
1077
|
-
correctly using the `#as_json` hook.
|
595
|
+
Event.create!(name: 'Rock Fest', duration: 2.days)
|
596
|
+
Event.last.duration # => 2 days
|
597
|
+
Event.last.duration.iso8601 # => "P2D"
|
598
|
+
Event.new(duration: 'P1DT12H3S').duration # => 1 day, 12 hours, and 3 seconds
|
599
|
+
Event.new(duration: '1 day') # Unknown value will be ignored and NULL will be written to database
|
1078
600
|
|
1079
|
-
|
1080
|
-
([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
|
1081
|
-
|
1082
|
-
Fixes #15594.
|
1083
|
-
|
1084
|
-
*Jenn Cooper*
|
1085
|
-
|
1086
|
-
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
1087
|
-
|
1088
|
-
Fixes #15931.
|
1089
|
-
|
1090
|
-
*Jeff Browning*
|
1091
|
-
|
1092
|
-
* Calling `#empty?` on a `has_many` association would use the value from the
|
1093
|
-
counter cache if one exists.
|
601
|
+
*Andrey Novikov*
|
1094
602
|
|
1095
|
-
|
603
|
+
* Allow associations supporting the `dependent:` key to take `dependent: :destroy_async`.
|
1096
604
|
|
1097
|
-
|
1098
|
-
|
605
|
+
```ruby
|
606
|
+
class Account < ActiveRecord::Base
|
607
|
+
belongs_to :supplier, dependent: :destroy_async
|
608
|
+
end
|
609
|
+
```
|
1099
610
|
|
1100
|
-
|
611
|
+
`:destroy_async` will enqueue a job to destroy associated records in the background.
|
1101
612
|
|
1102
|
-
*
|
613
|
+
*DHH*, *George Claghorn*, *Cory Gwin*, *Rafael Mendonça França*, *Adrianna Chang*
|
1103
614
|
|
1104
|
-
*
|
1105
|
-
produce an `IN` statements.
|
615
|
+
* Add `SKIP_TEST_DATABASE` environment variable to disable modifying the test database when `rails db:create` and `rails db:drop` are called.
|
1106
616
|
|
1107
|
-
|
617
|
+
*Jason Schweier*
|
1108
618
|
|
1109
|
-
|
1110
|
-
"categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
|
1111
|
-
|
1112
|
-
After:
|
619
|
+
* `connects_to` can only be called on `ActiveRecord::Base` or abstract classes.
|
1113
620
|
|
1114
|
-
|
1115
|
-
"categorizations"."category_id" = 1
|
621
|
+
Ensure that `connects_to` can only be called from `ActiveRecord::Base` or abstract classes. This protects the application from opening duplicate or too many connections.
|
1116
622
|
|
1117
|
-
*Eileen M. Uchitelle
|
623
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1118
624
|
|
1119
|
-
*
|
1120
|
-
|
1121
|
-
values will be coerced to a numeric allowing false or 0.seconds match any
|
1122
|
-
string starting with a non-digit.
|
625
|
+
* All connection adapters `execute` now raises `ActiveRecord::ConnectionNotEstablished` rather than
|
626
|
+
`ActiveRecord::StatementInvalid` when they encounter a connection error.
|
1123
627
|
|
1124
|
-
|
628
|
+
*Jean Boussier*
|
1125
629
|
|
1126
|
-
|
630
|
+
* `Mysql2Adapter#quote_string` now raises `ActiveRecord::ConnectionNotEstablished` rather than
|
631
|
+
`ActiveRecord::StatementInvalid` when it can't connect to the MySQL server.
|
1127
632
|
|
1128
|
-
*
|
633
|
+
*Jean Boussier*
|
1129
634
|
|
1130
|
-
* Add
|
1131
|
-
API for presence validations on associations.
|
635
|
+
* Add support for check constraints that are `NOT VALID` via `validate: false` (PostgreSQL-only).
|
1132
636
|
|
1133
|
-
*
|
637
|
+
*Alex Robbin*
|
1134
638
|
|
1135
|
-
*
|
1136
|
-
(Call to `count` generated invalid SQL.)
|
639
|
+
* Ensure the default configuration is considered primary or first for an environment
|
1137
640
|
|
1138
|
-
|
641
|
+
If a multiple database application provides a configuration named primary, that will be treated as default. In applications that do not have a primary entry, the default database configuration will be the first configuration for an environment.
|
1139
642
|
|
1140
|
-
*
|
643
|
+
*Eileen M. Uchitelle*
|
1141
644
|
|
1142
|
-
|
645
|
+
* Allow `where` references association names as joined table name aliases.
|
1143
646
|
|
1144
|
-
|
647
|
+
```ruby
|
648
|
+
class Comment < ActiveRecord::Base
|
649
|
+
enum label: [:default, :child]
|
650
|
+
has_many :children, class_name: "Comment", foreign_key: :parent_id
|
651
|
+
end
|
1145
652
|
|
1146
|
-
|
653
|
+
# ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1
|
654
|
+
Comment.includes(:children).where("children.label": "child")
|
655
|
+
```
|
1147
656
|
|
1148
|
-
*
|
657
|
+
*Ryuta Kamizono*
|
1149
658
|
|
1150
|
-
*
|
1151
|
-
from `before_destroy` to `after_destroy` callback chain
|
659
|
+
* Support storing demodulized class name for polymorphic type.
|
1152
660
|
|
1153
|
-
|
661
|
+
Before Rails 6.1, storing demodulized class name is supported only for STI type
|
662
|
+
by `store_full_sti_class` class attribute.
|
1154
663
|
|
1155
|
-
|
664
|
+
Now `store_full_class_name` class attribute can handle both STI and polymorphic types.
|
1156
665
|
|
1157
|
-
*
|
666
|
+
*Ryuta Kamizono*
|
1158
667
|
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
668
|
+
* Deprecate `rails db:structure:{load, dump}` tasks and extend
|
669
|
+
`rails db:schema:{load, dump}` tasks to work with either `:ruby` or `:sql` format,
|
670
|
+
depending on `config.active_record.schema_format` configuration value.
|
1162
671
|
|
1163
|
-
|
672
|
+
*fatkodima*
|
1164
673
|
|
1165
|
-
|
1166
|
-
user.name << ' Griffin'
|
1167
|
-
user.name_will_change!
|
1168
|
-
user.save
|
1169
|
-
user.reload.name # => "Sean Griffin"
|
674
|
+
* Respect the `select` values for eager loading.
|
1170
675
|
|
1171
|
-
|
676
|
+
```ruby
|
677
|
+
post = Post.select("UPPER(title) AS title").first
|
678
|
+
post.title # => "WELCOME TO THE WEBLOG"
|
679
|
+
post.body # => ActiveModel::MissingAttributeError
|
1172
680
|
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
681
|
+
# Rails 6.0 (ignore the `select` values)
|
682
|
+
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
683
|
+
post.title # => "Welcome to the weblog"
|
684
|
+
post.body # => "Such a lovely day"
|
1177
685
|
|
1178
|
-
|
686
|
+
# Rails 6.1 (respect the `select` values)
|
687
|
+
post = Post.select("UPPER(title) AS title").eager_load(:comments).first
|
688
|
+
post.title # => "WELCOME TO THE WEBLOG"
|
689
|
+
post.body # => ActiveModel::MissingAttributeError
|
690
|
+
```
|
1179
691
|
|
1180
|
-
*
|
1181
|
-
is invalid.
|
692
|
+
*Ryuta Kamizono*
|
1182
693
|
|
1183
|
-
|
694
|
+
* Allow attribute's default to be configured but keeping its own type.
|
1184
695
|
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
696
|
+
```ruby
|
697
|
+
class Post < ActiveRecord::Base
|
698
|
+
attribute :written_at, default: -> { Time.now.utc }
|
699
|
+
end
|
1188
700
|
|
1189
|
-
|
1190
|
-
|
701
|
+
# Rails 6.0
|
702
|
+
Post.type_for_attribute(:written_at) # => #<Type::Value ... precision: nil, ...>
|
1191
703
|
|
1192
|
-
|
704
|
+
# Rails 6.1
|
705
|
+
Post.type_for_attribute(:written_at) # => #<Type::DateTime ... precision: 6, ...>
|
706
|
+
```
|
1193
707
|
|
1194
|
-
|
1195
|
-
add_foreign_key :articles, :authors
|
1196
|
-
remove_foreign_key :articles, :authors
|
708
|
+
*Ryuta Kamizono*
|
1197
709
|
|
1198
|
-
|
710
|
+
* Allow default to be configured for Enum.
|
1199
711
|
|
1200
|
-
|
1201
|
-
|
712
|
+
```ruby
|
713
|
+
class Book < ActiveRecord::Base
|
714
|
+
enum status: [:proposed, :written, :published], _default: :published
|
715
|
+
end
|
1202
716
|
|
1203
|
-
|
717
|
+
Book.new.status # => "published"
|
718
|
+
```
|
1204
719
|
|
1205
|
-
*
|
1206
|
-
broken and inconsistent.
|
720
|
+
*Ryuta Kamizono*
|
1207
721
|
|
1208
|
-
|
722
|
+
* Deprecate YAML loading from legacy format older than Rails 5.0.
|
1209
723
|
|
1210
|
-
*
|
724
|
+
*Ryuta Kamizono*
|
1211
725
|
|
1212
|
-
|
726
|
+
* Added the setting `ActiveRecord::Base.immutable_strings_by_default`, which
|
727
|
+
allows you to specify that all string columns should be frozen unless
|
728
|
+
otherwise specified. This will reduce memory pressure for applications which
|
729
|
+
do not generally mutate string properties of Active Record objects.
|
1213
730
|
|
1214
|
-
*
|
731
|
+
*Sean Griffin*, *Ryuta Kamizono*
|
1215
732
|
|
1216
|
-
*
|
1217
|
-
would fail numericality validation, regardless of the old value. Previously
|
1218
|
-
this would only occur if the old value was 0.
|
733
|
+
* Deprecate `map!` and `collect!` on `ActiveRecord::Result`.
|
1219
734
|
|
1220
|
-
|
735
|
+
*Ryuta Kamizono*
|
1221
736
|
|
1222
|
-
|
1223
|
-
model.number = '5wibble'
|
1224
|
-
model.number_changed? # => true
|
737
|
+
* Support `relation.and` for intersection as Set theory.
|
1225
738
|
|
1226
|
-
|
739
|
+
```ruby
|
740
|
+
david_and_mary = Author.where(id: [david, mary])
|
741
|
+
mary_and_bob = Author.where(id: [mary, bob])
|
1227
742
|
|
1228
|
-
|
743
|
+
david_and_mary.merge(mary_and_bob) # => [mary, bob]
|
1229
744
|
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
745
|
+
david_and_mary.and(mary_and_bob) # => [mary]
|
746
|
+
david_and_mary.or(mary_and_bob) # => [david, mary, bob]
|
747
|
+
```
|
1233
748
|
|
1234
|
-
*
|
749
|
+
*Ryuta Kamizono*
|
1235
750
|
|
1236
|
-
*
|
1237
|
-
|
751
|
+
* Merging conditions on the same column no longer maintain both conditions,
|
752
|
+
and will be consistently replaced by the latter condition in Rails 6.2.
|
753
|
+
To migrate to Rails 6.2's behavior, use `relation.merge(other, rewhere: true)`.
|
1238
754
|
|
1239
|
-
|
755
|
+
```ruby
|
756
|
+
# Rails 6.1 (IN clause is replaced by merger side equality condition)
|
757
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
1240
758
|
|
1241
|
-
|
759
|
+
# Rails 6.1 (both conflict conditions exists, deprecated)
|
760
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
|
1242
761
|
|
1243
|
-
|
762
|
+
# Rails 6.1 with rewhere to migrate to Rails 6.2's behavior
|
763
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
|
1244
764
|
|
1245
|
-
|
765
|
+
# Rails 6.2 (same behavior with IN clause, mergee side condition is consistently replaced)
|
766
|
+
Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
|
767
|
+
Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
|
768
|
+
```
|
1246
769
|
|
1247
|
-
*
|
770
|
+
*Ryuta Kamizono*
|
1248
771
|
|
1249
|
-
*
|
772
|
+
* Do not mark Postgresql MAC address and UUID attributes as changed when the assigned value only varies by case.
|
1250
773
|
|
1251
|
-
*
|
774
|
+
*Peter Fry*
|
1252
775
|
|
1253
|
-
*
|
1254
|
-
are part of the URI structure, not the actual host.
|
776
|
+
* Resolve issue with insert_all unique_by option when used with expression index.
|
1255
777
|
|
1256
|
-
|
778
|
+
When the `:unique_by` option of `ActiveRecord::Persistence.insert_all` and
|
779
|
+
`ActiveRecord::Persistence.upsert_all` was used with the name of an expression index, an error
|
780
|
+
was raised. Adding a guard around the formatting behavior for the `:unique_by` corrects this.
|
1257
781
|
|
1258
|
-
|
782
|
+
Usage:
|
1259
783
|
|
1260
|
-
|
1261
|
-
|
784
|
+
```ruby
|
785
|
+
create_table :books, id: :integer, force: true do |t|
|
786
|
+
t.column :name, :string
|
787
|
+
t.index "lower(name)", unique: true
|
788
|
+
end
|
1262
789
|
|
1263
|
-
|
790
|
+
Book.insert_all [{ name: "MyTest" }], unique_by: :index_books_on_lower_name
|
791
|
+
```
|
1264
792
|
|
1265
|
-
|
1266
|
-
Serialized attributes on ActiveRecord models will no longer save when
|
1267
|
-
unchanged.
|
793
|
+
Fixes #39516.
|
1268
794
|
|
1269
|
-
|
795
|
+
*Austen Madden*
|
1270
796
|
|
1271
|
-
|
797
|
+
* Add basic support for CHECK constraints to database migrations.
|
1272
798
|
|
1273
|
-
|
1274
|
-
name.
|
799
|
+
Usage:
|
1275
800
|
|
1276
|
-
|
801
|
+
```ruby
|
802
|
+
add_check_constraint :products, "price > 0", name: "price_check"
|
803
|
+
remove_check_constraint :products, name: "price_check"
|
804
|
+
```
|
1277
805
|
|
1278
|
-
*
|
806
|
+
*fatkodima*
|
1279
807
|
|
1280
|
-
*
|
808
|
+
* Add `ActiveRecord::Base.strict_loading_by_default` and `ActiveRecord::Base.strict_loading_by_default=`
|
809
|
+
to enable/disable strict_loading mode by default for a model. The configuration's value is
|
810
|
+
inheritable by subclasses, but they can override that value and it will not impact parent class.
|
1281
811
|
|
1282
|
-
|
812
|
+
Usage:
|
1283
813
|
|
1284
|
-
|
814
|
+
```ruby
|
815
|
+
class Developer < ApplicationRecord
|
816
|
+
self.strict_loading_by_default = true
|
1285
817
|
|
1286
|
-
|
818
|
+
has_many :projects
|
819
|
+
end
|
1287
820
|
|
1288
|
-
|
1289
|
-
|
821
|
+
dev = Developer.first
|
822
|
+
dev.projects.first
|
823
|
+
# => ActiveRecord::StrictLoadingViolationError Exception: Developer is marked as strict_loading and Project cannot be lazily loaded.
|
824
|
+
```
|
1290
825
|
|
1291
|
-
|
826
|
+
*bogdanvlviv*
|
1292
827
|
|
1293
|
-
|
828
|
+
* Deprecate passing an Active Record object to `quote`/`type_cast` directly.
|
1294
829
|
|
1295
|
-
*
|
830
|
+
*Ryuta Kamizono*
|
1296
831
|
|
1297
|
-
|
832
|
+
* Default engine `ENGINE=InnoDB` is no longer dumped to make schema more agnostic.
|
1298
833
|
|
1299
|
-
|
834
|
+
Before:
|
1300
835
|
|
1301
|
-
|
1302
|
-
|
836
|
+
```ruby
|
837
|
+
create_table "accounts", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", force: :cascade do |t|
|
838
|
+
end
|
839
|
+
```
|
1303
840
|
|
1304
|
-
|
841
|
+
After:
|
1305
842
|
|
1306
|
-
|
843
|
+
```ruby
|
844
|
+
create_table "accounts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
845
|
+
end
|
846
|
+
```
|
1307
847
|
|
1308
|
-
*
|
848
|
+
*Ryuta Kamizono*
|
1309
849
|
|
1310
|
-
|
850
|
+
* Added delegated type as an alternative to single-table inheritance for representing class hierarchies.
|
851
|
+
See ActiveRecord::DelegatedType for the full description.
|
1311
852
|
|
1312
|
-
*
|
853
|
+
*DHH*
|
1313
854
|
|
1314
|
-
*
|
855
|
+
* Deprecate aggregations with group by duplicated fields.
|
1315
856
|
|
1316
|
-
|
1317
|
-
updated.
|
857
|
+
To migrate to Rails 6.2's behavior, use `uniq!(:group)` to deduplicate group fields.
|
1318
858
|
|
1319
|
-
|
859
|
+
```ruby
|
860
|
+
accounts = Account.group(:firm_id)
|
1320
861
|
|
1321
|
-
|
862
|
+
# duplicated group fields, deprecated.
|
863
|
+
accounts.merge(accounts.where.not(credit_limit: nil)).sum(:credit_limit)
|
864
|
+
# => {
|
865
|
+
# [1, 1] => 50,
|
866
|
+
# [2, 2] => 60
|
867
|
+
# }
|
1322
868
|
|
1323
|
-
|
1324
|
-
|
869
|
+
# use `uniq!(:group)` to deduplicate group fields.
|
870
|
+
accounts.merge(accounts.where.not(credit_limit: nil)).uniq!(:group).sum(:credit_limit)
|
871
|
+
# => {
|
872
|
+
# 1 => 50,
|
873
|
+
# 2 => 60
|
874
|
+
# }
|
875
|
+
```
|
1325
876
|
|
1326
|
-
*
|
877
|
+
*Ryuta Kamizono*
|
1327
878
|
|
1328
|
-
*
|
1329
|
-
existing column.
|
879
|
+
* Deprecate duplicated query annotations.
|
1330
880
|
|
1331
|
-
|
881
|
+
To migrate to Rails 6.2's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
|
1332
882
|
|
1333
|
-
|
883
|
+
```ruby
|
884
|
+
accounts = Account.where(id: [1, 2]).annotate("david and mary")
|
1334
885
|
|
1335
|
-
|
1336
|
-
|
886
|
+
# duplicated annotations, deprecated.
|
887
|
+
accounts.merge(accounts.rewhere(id: 3))
|
888
|
+
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */ /* david and mary */
|
1337
889
|
|
1338
|
-
|
890
|
+
# use `uniq!(:annotate)` to deduplicate annotations.
|
891
|
+
accounts.merge(accounts.rewhere(id: 3)).uniq!(:annotate)
|
892
|
+
# SELECT accounts.* FROM accounts WHERE accounts.id = 3 /* david and mary */
|
893
|
+
```
|
1339
894
|
|
1340
|
-
*
|
895
|
+
*Ryuta Kamizono*
|
1341
896
|
|
1342
|
-
|
897
|
+
* Resolve conflict between counter cache and optimistic locking.
|
1343
898
|
|
1344
|
-
|
1345
|
-
|
899
|
+
Bump an Active Record instance's lock version after updating its counter
|
900
|
+
cache. This avoids raising an unnecessary `ActiveRecord::StaleObjectError`
|
901
|
+
upon subsequent transactions by maintaining parity with the corresponding
|
902
|
+
database record's `lock_version` column.
|
1346
903
|
|
1347
|
-
|
904
|
+
Fixes #16449.
|
1348
905
|
|
1349
|
-
*
|
906
|
+
*Aaron Lipman*
|
1350
907
|
|
1351
|
-
|
908
|
+
* Support merging option `:rewhere` to allow mergee side condition to be replaced exactly.
|
1352
909
|
|
1353
|
-
|
910
|
+
```ruby
|
911
|
+
david_and_mary = Author.where(id: david.id..mary.id)
|
1354
912
|
|
1355
|
-
|
913
|
+
# both conflict conditions exists
|
914
|
+
david_and_mary.merge(Author.where(id: bob)) # => []
|
1356
915
|
|
1357
|
-
|
916
|
+
# mergee side condition is replaced by rewhere
|
917
|
+
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]
|
1358
918
|
|
1359
|
-
|
919
|
+
# mergee side condition is replaced by rewhere option
|
920
|
+
david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]
|
921
|
+
```
|
1360
922
|
|
1361
|
-
*
|
1362
|
-
with orders without sort direction modifiers.
|
923
|
+
*Ryuta Kamizono*
|
1363
924
|
|
1364
|
-
|
925
|
+
* Add support for finding records based on signed ids, which are tamper-proof, verified ids that can be
|
926
|
+
set to expire and scoped with a purpose. This is particularly useful for things like password reset
|
927
|
+
or email verification, where you want the bearer of the signed id to be able to interact with the
|
928
|
+
underlying record, but usually only within a certain time period.
|
1365
929
|
|
1366
|
-
|
930
|
+
```ruby
|
931
|
+
signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset
|
1367
932
|
|
1368
|
-
|
933
|
+
User.find_signed signed_id # => nil, since the purpose does not match
|
1369
934
|
|
1370
|
-
|
1371
|
-
|
935
|
+
travel 16.minutes
|
936
|
+
User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired
|
1372
937
|
|
1373
|
-
|
938
|
+
travel_back
|
939
|
+
User.find_signed signed_id, purpose: :password_reset # => User.first
|
1374
940
|
|
1375
|
-
|
941
|
+
User.find_signed! "bad data" # => ActiveSupport::MessageVerifier::InvalidSignature
|
942
|
+
```
|
1376
943
|
|
1377
|
-
*
|
944
|
+
*DHH*
|
1378
945
|
|
1379
|
-
|
946
|
+
* Support `ALGORITHM = INSTANT` DDL option for index operations on MySQL.
|
1380
947
|
|
1381
|
-
*
|
1382
|
-
Fixing regression case, where redefining the same `has_and_belongs_to_many`
|
1383
|
-
definition into a subclass would raise.
|
948
|
+
*Ryuta Kamizono*
|
1384
949
|
|
1385
|
-
|
950
|
+
* Fix index creation to preserve index comment in bulk change table on MySQL.
|
1386
951
|
|
1387
|
-
*
|
952
|
+
*Ryuta Kamizono*
|
1388
953
|
|
1389
|
-
*
|
1390
|
-
When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
|
1391
|
-
But as `reflections` is a public API, people expect to see the right macro.
|
954
|
+
* Allow `unscope` to be aware of table name qualified values.
|
1392
955
|
|
1393
|
-
|
956
|
+
It is possible to unscope only the column in the specified table.
|
1394
957
|
|
1395
|
-
|
958
|
+
```ruby
|
959
|
+
posts = Post.joins(:comments).group(:"posts.hidden")
|
960
|
+
posts = posts.where("posts.hidden": false, "comments.hidden": false)
|
1396
961
|
|
1397
|
-
|
962
|
+
posts.count
|
963
|
+
# => { false => 10 }
|
1398
964
|
|
1399
|
-
|
965
|
+
# unscope both hidden columns
|
966
|
+
posts.unscope(where: :hidden).count
|
967
|
+
# => { false => 11, true => 1 }
|
1400
968
|
|
1401
|
-
|
969
|
+
# unscope only comments.hidden column
|
970
|
+
posts.unscope(where: :"comments.hidden").count
|
971
|
+
# => { false => 11 }
|
972
|
+
```
|
1402
973
|
|
1403
|
-
*
|
1404
|
-
on a NullRelation should return a Hash.
|
974
|
+
*Ryuta Kamizono*, *Slava Korolev*
|
1405
975
|
|
1406
|
-
|
976
|
+
* Fix `rewhere` to truly overwrite collided where clause by new where clause.
|
1407
977
|
|
1408
|
-
|
1409
|
-
|
978
|
+
```ruby
|
979
|
+
steve = Person.find_by(name: "Steve")
|
980
|
+
david = Author.find_by(name: "David")
|
1410
981
|
|
1411
|
-
|
982
|
+
relation = Essay.where(writer: steve)
|
1412
983
|
|
1413
|
-
|
984
|
+
# Before
|
985
|
+
relation.rewhere(writer: david).to_a # => []
|
1414
986
|
|
1415
|
-
|
987
|
+
# After
|
988
|
+
relation.rewhere(writer: david).to_a # => [david]
|
989
|
+
```
|
1416
990
|
|
1417
|
-
*
|
991
|
+
*Ryuta Kamizono*
|
1418
992
|
|
1419
|
-
*
|
993
|
+
* Inspect time attributes with subsec and time zone offset.
|
1420
994
|
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
995
|
+
```ruby
|
996
|
+
p Knot.create
|
997
|
+
=> #<Knot id: 1, created_at: "2016-05-05 01:29:47.116928000 +0000">
|
998
|
+
```
|
1424
999
|
|
1425
|
-
*
|
1000
|
+
*akinomaeni*, *Jonathan Hefner*
|
1426
1001
|
|
1427
|
-
*
|
1428
|
-
table inside a schema.
|
1002
|
+
* Deprecate passing a column to `type_cast`.
|
1429
1003
|
|
1430
|
-
|
1004
|
+
*Ryuta Kamizono*
|
1431
1005
|
|
1432
|
-
|
1006
|
+
* Deprecate `in_clause_length` and `allowed_index_name_length` in `DatabaseLimits`.
|
1433
1007
|
|
1434
|
-
*
|
1435
|
-
in all cases. Fixes inconsistencies when column types are sent outside of
|
1436
|
-
`ActiveRecord`, such as for XML Serialization.
|
1008
|
+
*Ryuta Kamizono*
|
1437
1009
|
|
1438
|
-
|
1010
|
+
* Support bulk insert/upsert on relation to preserve scope values.
|
1439
1011
|
|
1440
|
-
*
|
1441
|
-
extension names in PostgreSQL when migrating.
|
1012
|
+
*Josef Šimánek*, *Ryuta Kamizono*
|
1442
1013
|
|
1443
|
-
|
1014
|
+
* Preserve column comment value on changing column name on MySQL.
|
1444
1015
|
|
1445
|
-
*
|
1446
|
-
`references`, now works with any column types.
|
1016
|
+
*Islam Taha*
|
1447
1017
|
|
1448
|
-
|
1018
|
+
* Add support for `if_exists` option for removing an index.
|
1449
1019
|
|
1450
|
-
|
1020
|
+
The `remove_index` method can take an `if_exists` option. If this is set to true an error won't be raised if the index doesn't exist.
|
1451
1021
|
|
1452
|
-
*
|
1022
|
+
*Eileen M. Uchitelle*
|
1453
1023
|
|
1454
|
-
*
|
1455
|
-
or `offset`.
|
1024
|
+
* Remove ibm_db, informix, mssql, oracle, and oracle12 Arel visitors which are not used in the code base.
|
1456
1025
|
|
1457
|
-
|
1458
|
-
records to be deleted.
|
1026
|
+
*Ryuta Kamizono*
|
1459
1027
|
|
1460
|
-
|
1028
|
+
* Prevent `build_association` from `touching` a parent record if the record isn't persisted for `has_one` associations.
|
1461
1029
|
|
1462
|
-
|
1030
|
+
Fixes #38219.
|
1463
1031
|
|
1464
|
-
*
|
1465
|
-
their limit dropped from the schema.
|
1032
|
+
*Josh Brody*
|
1466
1033
|
|
1467
|
-
|
1034
|
+
* Add support for `if_not_exists` option for adding index.
|
1468
1035
|
|
1469
|
-
|
1036
|
+
The `add_index` method respects `if_not_exists` option. If it is set to true
|
1037
|
+
index won't be added.
|
1470
1038
|
|
1471
|
-
|
1472
|
-
association.
|
1039
|
+
Usage:
|
1473
1040
|
|
1474
|
-
|
1041
|
+
```ruby
|
1042
|
+
add_index :users, :account_id, if_not_exists: true
|
1043
|
+
```
|
1475
1044
|
|
1476
|
-
|
1045
|
+
The `if_not_exists` option passed to `create_table` also gets propagated to indexes
|
1046
|
+
created within that migration so that if table and its indexes exist then there is no
|
1047
|
+
attempt to create them again.
|
1477
1048
|
|
1478
|
-
*
|
1479
|
-
strings in column names as equal.
|
1049
|
+
*Prathamesh Sonpatki*
|
1480
1050
|
|
1481
|
-
|
1482
|
-
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
1483
|
-
throw a `StatementInvalid` exception.
|
1051
|
+
* Add `ActiveRecord::Base#previously_new_record?` to show if a record was new before the last save.
|
1484
1052
|
|
1485
|
-
*
|
1053
|
+
*Tom Ward*
|
1486
1054
|
|
1487
|
-
*
|
1488
|
-
attributes defined in parent classes.
|
1055
|
+
* Support descending order for `find_each`, `find_in_batches`, and `in_batches`.
|
1489
1056
|
|
1490
|
-
|
1057
|
+
Batch processing methods allow you to work with the records in batches, greatly reducing memory consumption, but records are always batched from oldest id to newest.
|
1491
1058
|
|
1492
|
-
|
1059
|
+
This change allows reversing the order, batching from newest to oldest. This is useful when you need to process newer batches of records first.
|
1493
1060
|
|
1494
|
-
|
1061
|
+
Pass `order: :desc` to yield batches in descending order. The default remains `order: :asc`.
|
1495
1062
|
|
1496
|
-
|
1063
|
+
```ruby
|
1064
|
+
Person.find_each(order: :desc) do |person|
|
1065
|
+
person.party_all_night!
|
1066
|
+
end
|
1067
|
+
```
|
1497
1068
|
|
1498
|
-
*
|
1069
|
+
*Alexey Vasiliev*
|
1499
1070
|
|
1500
|
-
*
|
1071
|
+
* Fix `insert_all` with enum values.
|
1501
1072
|
|
1502
|
-
|
1503
|
-
PostgreSQL and are used by internal system catalogs. These field types
|
1504
|
-
can sometimes show up in structure-sniffing queries that feature internal system
|
1505
|
-
structures or with certain PostgreSQL extensions.
|
1073
|
+
Fixes #38716.
|
1506
1074
|
|
1507
|
-
*
|
1075
|
+
*Joel Blum*
|
1508
1076
|
|
1509
|
-
*
|
1510
|
-
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
1077
|
+
* Add support for `db:rollback:name` for multiple database applications.
|
1511
1078
|
|
1512
|
-
|
1079
|
+
Multiple database applications will now raise if `db:rollback` is call and recommend using the `db:rollback:[NAME]` to rollback migrations.
|
1513
1080
|
|
1514
|
-
|
1515
|
-
Point.last.value # => 0.0
|
1081
|
+
*Eileen M. Uchitelle*
|
1516
1082
|
|
1517
|
-
|
1083
|
+
* `Relation#pick` now uses already loaded results instead of making another query.
|
1518
1084
|
|
1519
|
-
|
1520
|
-
Point.last.value # => Infinity
|
1085
|
+
*Eugene Kenny*
|
1521
1086
|
|
1522
|
-
|
1087
|
+
* Deprecate using `return`, `break` or `throw` to exit a transaction block after writes.
|
1523
1088
|
|
1524
|
-
*
|
1089
|
+
*Dylan Thacker-Smith*
|
1525
1090
|
|
1526
|
-
|
1091
|
+
* Dump the schema or structure of a database when calling `db:migrate:name`.
|
1527
1092
|
|
1528
|
-
|
1093
|
+
In previous versions of Rails, `rails db:migrate` would dump the schema of the database. In Rails 6, that holds true (`rails db:migrate` dumps all databases' schemas), but `rails db:migrate:name` does not share that behavior.
|
1529
1094
|
|
1530
|
-
|
1531
|
-
associations without replacement. These operations happen before instances
|
1532
|
-
are created. The current behavior is unexpected and can result in broken
|
1533
|
-
behavior.
|
1095
|
+
Going forward, calls to `rails db:migrate:name` will dump the schema (or structure) of the database being migrated.
|
1534
1096
|
|
1535
|
-
|
1097
|
+
*Kyle Thompson*
|
1536
1098
|
|
1537
|
-
|
1099
|
+
* Reset the `ActiveRecord::Base` connection after `rails db:migrate:name`.
|
1538
1100
|
|
1539
|
-
|
1101
|
+
When `rails db:migrate` has finished, it ensures the `ActiveRecord::Base` connection is reset to its original configuration. Going forward, `rails db:migrate:name` will have the same behavior.
|
1540
1102
|
|
1541
|
-
|
1542
|
-
size calculation if the collection is not cached or loaded.
|
1103
|
+
*Kyle Thompson*
|
1543
1104
|
|
1544
|
-
|
1105
|
+
* Disallow calling `connected_to` on subclasses of `ActiveRecord::Base`.
|
1545
1106
|
|
1546
|
-
|
1107
|
+
Behavior has not changed here but the previous API could be misleading to people who thought it would switch connections for only that class. `connected_to` switches the context from which we are getting connections, not the connections themselves.
|
1547
1108
|
|
1548
|
-
*
|
1549
|
-
not exist.
|
1109
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1550
1110
|
|
1551
|
-
|
1111
|
+
* Add support for horizontal sharding to `connects_to` and `connected_to`.
|
1552
1112
|
|
1553
|
-
|
1113
|
+
Applications can now connect to multiple shards and switch between their shards in an application. Note that the shard swapping is still a manual process as this change does not include an API for automatic shard swapping.
|
1554
1114
|
|
1555
|
-
|
1556
|
-
using namespaced models.
|
1115
|
+
Usage:
|
1557
1116
|
|
1558
|
-
|
1117
|
+
Given the following configuration:
|
1559
1118
|
|
1560
|
-
|
1119
|
+
```yaml
|
1120
|
+
# config/database.yml
|
1121
|
+
production:
|
1122
|
+
primary:
|
1123
|
+
database: my_database
|
1124
|
+
primary_shard_one:
|
1125
|
+
database: my_database_shard_one
|
1126
|
+
```
|
1561
1127
|
|
1562
|
-
|
1563
|
-
In 4.0 series it is delegated to `Array#join`.
|
1128
|
+
Connect to multiple shards:
|
1564
1129
|
|
1565
|
-
|
1130
|
+
```ruby
|
1131
|
+
class ApplicationRecord < ActiveRecord::Base
|
1132
|
+
self.abstract_class = true
|
1566
1133
|
|
1567
|
-
|
1134
|
+
connects_to shards: {
|
1135
|
+
default: { writing: :primary },
|
1136
|
+
shard_one: { writing: :primary_shard_one }
|
1137
|
+
}
|
1138
|
+
```
|
1568
1139
|
|
1569
|
-
|
1570
|
-
in that column, the SQL logger would throw an exception when trying
|
1571
|
-
to log that nil value. This only occurs when updating a record
|
1572
|
-
that already has a non-nil value in that column since an initial nil
|
1573
|
-
value isn't included in the SQL anyway (at least, when dirty checking
|
1574
|
-
is enabled.) The column's new value will now be logged as `<NULL binary data>`
|
1575
|
-
to parallel the existing `<N bytes of binary data>` for non-nil values.
|
1140
|
+
Swap between shards in your controller / model code:
|
1576
1141
|
|
1577
|
-
|
1142
|
+
```ruby
|
1143
|
+
ActiveRecord::Base.connected_to(shard: :shard_one) do
|
1144
|
+
# Read from shard one
|
1145
|
+
end
|
1146
|
+
```
|
1578
1147
|
|
1579
|
-
|
1580
|
-
in order to validate child associations with the same context.
|
1148
|
+
The horizontal sharding API also supports read replicas. See guides for more details.
|
1581
1149
|
|
1582
|
-
|
1150
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1583
1151
|
|
1584
|
-
|
1152
|
+
* Deprecate `spec_name` in favor of `name` on database configurations.
|
1585
1153
|
|
1586
|
-
|
1154
|
+
The accessors for `spec_name` on `configs_for` and `DatabaseConfig` are deprecated. Please use `name` instead.
|
1587
1155
|
|
1588
|
-
|
1589
|
-
was ignored and overwritten by strict mode option.
|
1156
|
+
Deprecated behavior:
|
1590
1157
|
|
1591
|
-
|
1158
|
+
```ruby
|
1159
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
1160
|
+
db_config.spec_name
|
1161
|
+
```
|
1592
1162
|
|
1593
|
-
|
1163
|
+
New behavior:
|
1594
1164
|
|
1595
|
-
|
1165
|
+
```ruby
|
1166
|
+
db_config = ActiveRecord::Base.configurations.configs_for(env_name: "development", name: "primary")
|
1167
|
+
db_config.name
|
1168
|
+
```
|
1596
1169
|
|
1597
|
-
|
1170
|
+
*Eileen M. Uchitelle*
|
1598
1171
|
|
1599
|
-
|
1172
|
+
* Add additional database-specific rake tasks for multi-database users.
|
1600
1173
|
|
1601
|
-
|
1174
|
+
Previously, `rails db:create`, `rails db:drop`, and `rails db:migrate` were the only rails tasks that could operate on a single
|
1175
|
+
database. For example:
|
1602
1176
|
|
1603
|
-
|
1177
|
+
```
|
1178
|
+
rails db:create
|
1179
|
+
rails db:create:primary
|
1180
|
+
rails db:create:animals
|
1181
|
+
rails db:drop
|
1182
|
+
rails db:drop:primary
|
1183
|
+
rails db:drop:animals
|
1184
|
+
rails db:migrate
|
1185
|
+
rails db:migrate:primary
|
1186
|
+
rails db:migrate:animals
|
1187
|
+
```
|
1604
1188
|
|
1605
|
-
|
1606
|
-
|
1607
|
-
uses the reflections to set database with fixtures.
|
1189
|
+
With these changes, `rails db:schema:dump`, `rails db:schema:load`, `rails db:structure:dump`, `rails db:structure:load` and
|
1190
|
+
`rails db:test:prepare` can additionally operate on a single database. For example:
|
1608
1191
|
|
1609
|
-
|
1192
|
+
```
|
1193
|
+
rails db:schema:dump
|
1194
|
+
rails db:schema:dump:primary
|
1195
|
+
rails db:schema:dump:animals
|
1196
|
+
rails db:schema:load
|
1197
|
+
rails db:schema:load:primary
|
1198
|
+
rails db:schema:load:animals
|
1199
|
+
rails db:structure:dump
|
1200
|
+
rails db:structure:dump:primary
|
1201
|
+
rails db:structure:dump:animals
|
1202
|
+
rails db:structure:load
|
1203
|
+
rails db:structure:load:primary
|
1204
|
+
rails db:structure:load:animals
|
1205
|
+
rails db:test:prepare
|
1206
|
+
rails db:test:prepare:primary
|
1207
|
+
rails db:test:prepare:animals
|
1208
|
+
```
|
1610
1209
|
|
1611
|
-
*
|
1210
|
+
*Kyle Thompson*
|
1612
1211
|
|
1613
|
-
*
|
1614
|
-
Additionally display a warning message to make the user aware.
|
1212
|
+
* Add support for `strict_loading` mode on association declarations.
|
1615
1213
|
|
1616
|
-
|
1214
|
+
Raise an error if attempting to load a record from an association that has been marked as `strict_loading` unless it was explicitly eager loaded.
|
1617
1215
|
|
1618
|
-
|
1619
|
-
different spellings of timestamps are treated the same.
|
1216
|
+
Usage:
|
1620
1217
|
|
1621
|
-
|
1218
|
+
```ruby
|
1219
|
+
class Developer < ApplicationRecord
|
1220
|
+
has_many :projects, strict_loading: true
|
1221
|
+
end
|
1622
1222
|
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1223
|
+
dev = Developer.first
|
1224
|
+
dev.projects.first
|
1225
|
+
# => ActiveRecord::StrictLoadingViolationError: The projects association is marked as strict_loading and cannot be lazily loaded.
|
1226
|
+
```
|
1627
1227
|
|
1628
|
-
|
1228
|
+
*Kevin Deisz*
|
1629
1229
|
|
1630
|
-
|
1230
|
+
* Add support for `strict_loading` mode to prevent lazy loading of records.
|
1631
1231
|
|
1632
|
-
|
1232
|
+
Raise an error if a parent record is marked as `strict_loading` and attempts to lazily load its associations. This is useful for finding places you may want to preload an association and avoid additional queries.
|
1633
1233
|
|
1634
|
-
|
1234
|
+
Usage:
|
1635
1235
|
|
1636
|
-
|
1236
|
+
```ruby
|
1237
|
+
dev = Developer.strict_loading.first
|
1238
|
+
dev.audit_logs.to_a
|
1239
|
+
# => ActiveRecord::StrictLoadingViolationError: Developer is marked as strict_loading and AuditLog cannot be lazily loaded.
|
1240
|
+
```
|
1637
1241
|
|
1638
|
-
*
|
1242
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1639
1243
|
|
1640
|
-
|
1244
|
+
* Add support for PostgreSQL 11+ partitioned indexes when using `upsert_all`.
|
1641
1245
|
|
1642
|
-
*
|
1246
|
+
*Sebastián Palma*
|
1643
1247
|
|
1644
|
-
*
|
1645
|
-
a scoped `has_many`.
|
1248
|
+
* Adds support for `if_not_exists` to `add_column` and `if_exists` to `remove_column`.
|
1646
1249
|
|
1647
|
-
|
1648
|
-
`has_many :through` uses this association, then the scope adjustment is
|
1649
|
-
unexpectedly neglected.
|
1250
|
+
Applications can set their migrations to ignore exceptions raised when adding a column that already exists or when removing a column that does not exist.
|
1650
1251
|
|
1651
|
-
|
1252
|
+
Example Usage:
|
1652
1253
|
|
1653
|
-
|
1254
|
+
```ruby
|
1255
|
+
class AddColumnTitle < ActiveRecord::Migration[6.1]
|
1256
|
+
def change
|
1257
|
+
add_column :posts, :title, :string, if_not_exists: true
|
1258
|
+
end
|
1259
|
+
end
|
1260
|
+
```
|
1654
1261
|
|
1655
|
-
|
1262
|
+
```ruby
|
1263
|
+
class RemoveColumnTitle < ActiveRecord::Migration[6.1]
|
1264
|
+
def change
|
1265
|
+
remove_column :posts, :title, if_exists: true
|
1266
|
+
end
|
1267
|
+
end
|
1268
|
+
```
|
1656
1269
|
|
1657
|
-
*
|
1270
|
+
*Eileen M. Uchitelle*
|
1658
1271
|
|
1659
|
-
*
|
1272
|
+
* Regexp-escape table name for MS SQL Server.
|
1660
1273
|
|
1661
|
-
|
1274
|
+
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.
|
1662
1275
|
|
1663
|
-
*
|
1276
|
+
*Larry Reid*
|
1664
1277
|
|
1665
|
-
*
|
1278
|
+
* Store advisory locks on their own named connection.
|
1666
1279
|
|
1667
|
-
|
1280
|
+
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.
|
1668
1281
|
|
1669
|
-
|
1282
|
+
In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdvisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
|
1670
1283
|
|
1671
|
-
*
|
1672
|
-
LIKE statement.
|
1284
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1673
1285
|
|
1674
|
-
|
1286
|
+
* Allow schema cache path to be defined in the database configuration file.
|
1675
1287
|
|
1676
|
-
|
1677
|
-
def self.search(term)
|
1678
|
-
where("title LIKE ?", sanitize_sql_like(term))
|
1679
|
-
end
|
1680
|
-
end
|
1288
|
+
For example:
|
1681
1289
|
|
1682
|
-
|
1683
|
-
|
1290
|
+
```yaml
|
1291
|
+
development:
|
1292
|
+
adapter: postgresql
|
1293
|
+
database: blog_development
|
1294
|
+
pool: 5
|
1295
|
+
schema_cache_path: tmp/schema/main.yml
|
1296
|
+
```
|
1684
1297
|
|
1685
|
-
*
|
1298
|
+
*Katrina Owen*
|
1686
1299
|
|
1687
|
-
*
|
1300
|
+
* Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
|
1688
1301
|
|
1689
|
-
|
1302
|
+
`#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in 6.2.
|
1690
1303
|
|
1691
|
-
*
|
1304
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1692
1305
|
|
1693
|
-
*
|
1306
|
+
* Deprecate `#default_hash` and it's alias `#[]` on database configurations.
|
1694
1307
|
|
1695
|
-
|
1308
|
+
Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in 6.2.
|
1696
1309
|
|
1697
|
-
|
1698
|
-
# => true
|
1699
|
-
Post.where(author_id: author.id) == author.posts
|
1700
|
-
# => true
|
1310
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1701
1311
|
|
1702
|
-
|
1312
|
+
* Add scale support to `ActiveRecord::Validations::NumericalityValidator`.
|
1703
1313
|
|
1704
|
-
*
|
1314
|
+
*Gannon McGibbon*
|
1705
1315
|
|
1706
|
-
*
|
1707
|
-
generates an SQL statement containing each id of the collection:
|
1316
|
+
* Find orphans by looking for missing relations through chaining `where.missing`:
|
1708
1317
|
|
1709
1318
|
Before:
|
1710
1319
|
|
1711
|
-
|
1712
|
-
|
1320
|
+
```ruby
|
1321
|
+
Post.left_joins(:author).where(authors: { id: nil })
|
1322
|
+
```
|
1713
1323
|
|
1714
1324
|
After:
|
1715
1325
|
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
|
1721
|
-
with `select`.
|
1722
|
-
|
1723
|
-
Fixes #13648.
|
1724
|
-
|
1725
|
-
*Simon Woker*
|
1726
|
-
|
1727
|
-
* PostgreSQL adapter only warns once for every missing OID per connection.
|
1326
|
+
```ruby
|
1327
|
+
Post.where.missing(:author)
|
1328
|
+
```
|
1728
1329
|
|
1729
|
-
|
1330
|
+
*Tom Rossi*
|
1730
1331
|
|
1731
|
-
|
1332
|
+
* Ensure `:reading` connections always raise if a write is attempted.
|
1732
1333
|
|
1733
|
-
|
1734
|
-
unknown OIDs.
|
1334
|
+
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`.
|
1735
1335
|
|
1736
|
-
|
1336
|
+
*Eileen M. Uchitelle*
|
1737
1337
|
|
1738
|
-
|
1338
|
+
* Deprecate `"primary"` as the `connection_specification_name` for `ActiveRecord::Base`.
|
1739
1339
|
|
1740
|
-
|
1340
|
+
`"primary"` has been deprecated as the `connection_specification_name` for `ActiveRecord::Base` in favor of using `"ActiveRecord::Base"`. This change affects calls to `ActiveRecord::Base.connection_handler.retrieve_connection` and `ActiveRecord::Base.connection_handler.remove_connection`. If you're calling these methods with `"primary"`, please switch to `"ActiveRecord::Base"`.
|
1741
1341
|
|
1742
|
-
|
1342
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1743
1343
|
|
1744
|
-
|
1344
|
+
* Add `ActiveRecord::Validations::NumericalityValidator` with
|
1345
|
+
support for casting floats using a database columns' precision value.
|
1745
1346
|
|
1746
|
-
*
|
1347
|
+
*Gannon McGibbon*
|
1747
1348
|
|
1748
|
-
|
1349
|
+
* Enforce fresh ETag header after a collection's contents change by adding
|
1350
|
+
ActiveRecord::Relation#cache_key_with_version. This method will be used by
|
1351
|
+
ActionController::ConditionalGet to ensure that when collection cache versioning
|
1352
|
+
is enabled, requests using ConditionalGet don't return the same ETag header
|
1353
|
+
after a collection is modified.
|
1749
1354
|
|
1750
|
-
|
1355
|
+
Fixes #38078.
|
1751
1356
|
|
1752
|
-
*
|
1753
|
-
same name in an unrelated class.
|
1357
|
+
*Aaron Lipman*
|
1754
1358
|
|
1755
|
-
|
1359
|
+
* Skip test database when running `db:create` or `db:drop` in development
|
1360
|
+
with `DATABASE_URL` set.
|
1756
1361
|
|
1757
|
-
*
|
1362
|
+
*Brian Buchalter*
|
1758
1363
|
|
1759
|
-
*
|
1364
|
+
* Don't allow mutations on the database configurations hash.
|
1760
1365
|
|
1761
|
-
|
1366
|
+
Freeze the configurations hash to disallow directly changing it. If applications need to change the hash, for example to create databases for parallelization, they should use the `DatabaseConfig` object directly.
|
1762
1367
|
|
1763
|
-
|
1368
|
+
Before:
|
1764
1369
|
|
1765
|
-
|
1370
|
+
```ruby
|
1371
|
+
@db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
|
1372
|
+
@db_config.configuration_hash.merge!(idle_timeout: "0.02")
|
1373
|
+
```
|
1766
1374
|
|
1767
|
-
|
1375
|
+
After:
|
1768
1376
|
|
1769
|
-
|
1377
|
+
```ruby
|
1378
|
+
@db_config = ActiveRecord::Base.configurations.configs_for(env_name: "test", spec_name: "primary")
|
1379
|
+
config = @db_config.configuration_hash.merge(idle_timeout: "0.02")
|
1380
|
+
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@db_config.env_name, @db_config.spec_name, config)
|
1381
|
+
```
|
1770
1382
|
|
1771
|
-
*
|
1772
|
-
could previously have incorrectly accrued additional conditions (e.g. as a result of
|
1773
|
-
a previous query). `CollectionProxy` now always defers to the association scope's
|
1774
|
-
`arel` method so the (incorrect) inherited one should be entirely concealed.
|
1383
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1775
1384
|
|
1776
|
-
|
1385
|
+
* Remove `:connection_id` from the `sql.active_record` notification.
|
1777
1386
|
|
1778
|
-
*
|
1387
|
+
*Aaron Patterson*, *Rafael Mendonça França*
|
1779
1388
|
|
1780
|
-
*
|
1389
|
+
* The `:name` key will no longer be returned as part of `DatabaseConfig#configuration_hash`. Please use `DatabaseConfig#owner_name` instead.
|
1781
1390
|
|
1782
|
-
|
1391
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1783
1392
|
|
1784
|
-
|
1393
|
+
* ActiveRecord's `belongs_to_required_by_default` flag can now be set per model.
|
1785
1394
|
|
1786
|
-
|
1395
|
+
You can now opt-out/opt-in specific models from having their associations required
|
1396
|
+
by default.
|
1787
1397
|
|
1788
|
-
|
1398
|
+
This change is meant to ease the process of migrating all your models to have
|
1399
|
+
their association required.
|
1789
1400
|
|
1790
|
-
|
1401
|
+
*Edouard Chin*
|
1791
1402
|
|
1792
|
-
|
1403
|
+
* The `connection_config` method has been deprecated, please use `connection_db_config` instead which will return a `DatabaseConfigurations::DatabaseConfig` instead of a `Hash`.
|
1793
1404
|
|
1794
|
-
*
|
1795
|
-
deprecated in 4.1) from relative to absolute.
|
1405
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1796
1406
|
|
1797
|
-
|
1798
|
-
`sqlite3:///my/path` with `sqlite3:my/path`.
|
1407
|
+
* Retain explicit selections on the base model after applying `includes` and `joins`.
|
1799
1408
|
|
1800
|
-
|
1409
|
+
Resolves #34889.
|
1801
1410
|
|
1802
|
-
*
|
1411
|
+
*Patrick Rebsch*
|
1803
1412
|
|
1804
|
-
|
1413
|
+
* The `database` kwarg is deprecated without replacement because it can't be used for sharding and creates an issue if it's used during a request. Applications that need to create new connections should use `connects_to` instead.
|
1805
1414
|
|
1806
|
-
|
1415
|
+
*Eileen M. Uchitelle*, *John Crepezzi*
|
1807
1416
|
|
1808
|
-
|
1417
|
+
* Allow attributes to be fetched from Arel node groupings.
|
1809
1418
|
|
1810
|
-
*
|
1419
|
+
*Jeff Emminger*, *Gannon McGibbon*
|
1811
1420
|
|
1812
|
-
|
1421
|
+
* A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgreSQL `options`.
|
1813
1422
|
|
1814
|
-
*
|
1423
|
+
*Joshua Flanagan*
|
1815
1424
|
|
1816
|
-
|
1425
|
+
* Calling methods like `establish_connection` with a `Hash` which is invalid (eg: no `adapter`) will now raise an error the same way as connections defined in `config/database.yml`.
|
1817
1426
|
|
1818
|
-
*
|
1819
|
-
The column types stay the same except for enum columns. They no longer have
|
1820
|
-
`nil` as type but `enum`.
|
1427
|
+
*John Crepezzi*
|
1821
1428
|
|
1822
|
-
|
1429
|
+
* Specifying `implicit_order_column` now subsorts the records by primary key if available to ensure deterministic results.
|
1823
1430
|
|
1824
|
-
*
|
1431
|
+
*Paweł Urbanek*
|
1825
1432
|
|
1826
|
-
*
|
1827
|
-
column.
|
1433
|
+
* `where(attr => [])` now loads an empty result without making a query.
|
1828
1434
|
|
1829
|
-
|
1435
|
+
*John Hawthorn*
|
1830
1436
|
|
1831
|
-
|
1437
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
1832
1438
|
|
1833
|
-
*
|
1834
|
-
custom primary key that did not save due to validation error.
|
1439
|
+
*Hiroyuki Ishii*
|
1835
1440
|
|
1836
|
-
|
1441
|
+
* Add support for `belongs_to` to `has_many` inversing.
|
1837
1442
|
|
1838
|
-
*
|
1443
|
+
*Gannon McGibbon*
|
1839
1444
|
|
1840
|
-
*
|
1445
|
+
* Allow length configuration for `has_secure_token` method. The minimum length
|
1446
|
+
is set at 24 characters.
|
1841
1447
|
|
1842
|
-
|
1448
|
+
Before:
|
1843
1449
|
|
1844
|
-
|
1450
|
+
```ruby
|
1451
|
+
has_secure_token :auth_token
|
1452
|
+
```
|
1845
1453
|
|
1846
|
-
|
1454
|
+
After:
|
1847
1455
|
|
1848
|
-
|
1849
|
-
|
1456
|
+
```ruby
|
1457
|
+
has_secure_token :default_token # 24 characters
|
1458
|
+
has_secure_token :auth_token, length: 36 # 36 characters
|
1459
|
+
has_secure_token :invalid_token, length: 12 # => ActiveRecord::SecureToken::MinimumLengthError
|
1460
|
+
```
|
1850
1461
|
|
1851
|
-
|
1852
|
-
required.
|
1462
|
+
*Bernardo de Araujo*
|
1853
1463
|
|
1854
|
-
|
1464
|
+
* Deprecate `DatabaseConfigurations#to_h`. These connection hashes are still available via `ActiveRecord::Base.configurations.configs_for`.
|
1855
1465
|
|
1856
|
-
|
1857
|
-
t.index :zip
|
1858
|
-
end
|
1859
|
-
# => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
|
1466
|
+
*Eileen Uchitelle*, *John Crepezzi*
|
1860
1467
|
|
1861
|
-
|
1468
|
+
* Add `DatabaseConfig#configuration_hash` to return database configuration hashes with symbol keys, and use all symbol-key configuration hashes internally. Deprecate `DatabaseConfig#config` which returns a String-keyed `Hash` with the same values.
|
1862
1469
|
|
1863
|
-
*
|
1864
|
-
`ActiveRecord::Base.pluralize_table_names` is `false`.
|
1470
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
1865
1471
|
|
1866
|
-
|
1472
|
+
* Allow column names to be passed to `remove_index` positionally along with other options.
|
1867
1473
|
|
1868
|
-
|
1474
|
+
Passing other options can be necessary to make `remove_index` correctly reversible.
|
1869
1475
|
|
1870
|
-
|
1476
|
+
Before:
|
1871
1477
|
|
1872
|
-
|
1478
|
+
add_index :reports, :report_id # => works
|
1479
|
+
add_index :reports, :report_id, unique: true # => works
|
1480
|
+
remove_index :reports, :report_id # => works
|
1481
|
+
remove_index :reports, :report_id, unique: true # => ArgumentError
|
1873
1482
|
|
1874
|
-
|
1875
|
-
Photo.last.touch(:signed_at, :sealed_at)
|
1483
|
+
After:
|
1876
1484
|
|
1877
|
-
|
1485
|
+
remove_index :reports, :report_id, unique: true # => works
|
1878
1486
|
|
1879
|
-
*
|
1880
|
-
migration table exists.
|
1487
|
+
*Eugene Kenny*
|
1881
1488
|
|
1882
|
-
|
1489
|
+
* Allow bulk `ALTER` statements to drop and recreate indexes with the same name.
|
1883
1490
|
|
1884
|
-
*
|
1491
|
+
*Eugene Kenny*
|
1885
1492
|
|
1886
|
-
*
|
1887
|
-
of waiting until they disconnect by themselves. Before this change,
|
1888
|
-
a suitably constructed series of short-lived threads could starve
|
1889
|
-
the connection pool, without ever having more than a couple alive at
|
1890
|
-
the same time.
|
1493
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
1891
1494
|
|
1892
|
-
*
|
1495
|
+
*Eugene Kenny*
|
1893
1496
|
|
1894
|
-
* `
|
1895
|
-
pointing to pg_class, and thus only sequence objects, are considered.
|
1497
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
1896
1498
|
|
1897
|
-
|
1499
|
+
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)`.
|
1898
1500
|
|
1899
|
-
|
1501
|
+
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.
|
1900
1502
|
|
1901
|
-
|
1503
|
+
*Eileen M. Uchitelle*
|
1902
1504
|
|
1903
|
-
|
1505
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
1904
1506
|
|
1905
|
-
*
|
1507
|
+
*Kir Shatrov*
|
1906
1508
|
|
1907
|
-
|
1509
|
+
* Stop trying to read yaml file fixtures when loading Active Record fixtures.
|
1908
1510
|
|
1909
|
-
|
1910
|
-
email: $LABEL@email.com
|
1511
|
+
*Gannon McGibbon*
|
1911
1512
|
|
1912
|
-
|
1513
|
+
* Deprecate `.reorder(nil)` with `.first` / `.first!` taking non-deterministic result.
|
1913
1514
|
|
1914
|
-
|
1515
|
+
To continue taking non-deterministic result, use `.take` / `.take!` instead.
|
1915
1516
|
|
1916
|
-
*
|
1517
|
+
*Ryuta Kamizono*
|
1917
1518
|
|
1918
|
-
|
1519
|
+
* Preserve user supplied joins order as much as possible.
|
1919
1520
|
|
1920
|
-
|
1521
|
+
Fixes #36761, #34328, #24281, #12953.
|
1921
1522
|
|
1922
|
-
*
|
1923
|
-
Call `.id` on the object first.
|
1523
|
+
*Ryuta Kamizono*
|
1924
1524
|
|
1925
|
-
|
1525
|
+
* Allow `matches_regex` and `does_not_match_regexp` on the MySQL Arel visitor.
|
1926
1526
|
|
1927
|
-
*
|
1928
|
-
has a case insensitive collation.
|
1527
|
+
*James Pearson*
|
1929
1528
|
|
1930
|
-
|
1529
|
+
* Allow specifying fixtures to be ignored by setting `ignore` in YAML file's '_fixture' section.
|
1931
1530
|
|
1932
|
-
*
|
1531
|
+
*Tongfei Gao*
|
1933
1532
|
|
1934
|
-
|
1533
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
1935
1534
|
|
1936
|
-
*
|
1937
|
-
`where` values without needing to wrap in UPPER/LOWER sql functions.
|
1535
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
1938
1536
|
|
1939
|
-
|
1537
|
+
* Add a warning for enum elements with 'not_' prefix.
|
1940
1538
|
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1539
|
+
class Foo
|
1540
|
+
enum status: [:sent, :not_sent]
|
1541
|
+
end
|
1944
1542
|
|
1945
|
-
*
|
1543
|
+
*Edu Depetris*
|
1946
1544
|
|
1947
|
-
*
|
1545
|
+
* Make currency symbols optional for money column type in PostgreSQL.
|
1948
1546
|
|
1949
|
-
|
1547
|
+
*Joel Schneider*
|
1950
1548
|
|
1951
|
-
|
1549
|
+
* Add support for beginless ranges, introduced in Ruby 2.7.
|
1952
1550
|
|
1953
|
-
*
|
1551
|
+
*Josh Goodall*
|
1954
1552
|
|
1955
|
-
*
|
1956
|
-
warnings on enum columns.
|
1553
|
+
* Add `database_exists?` method to connection adapters to check if a database exists.
|
1957
1554
|
|
1958
|
-
*
|
1555
|
+
*Guilherme Mansur*
|
1959
1556
|
|
1960
|
-
*
|
1961
|
-
joins are involved.
|
1557
|
+
* Loading the schema for a model that has no `table_name` raises a `TableNotSpecified` error.
|
1962
1558
|
|
1963
|
-
|
1559
|
+
*Guilherme Mansur*, *Eugene Kenny*
|
1964
1560
|
|
1965
|
-
|
1561
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
1966
1562
|
|
1967
|
-
|
1968
|
-
any enum attribute is always evaluated as 0 during uniqueness validation.
|
1563
|
+
Fixes #36022.
|
1969
1564
|
|
1970
|
-
|
1565
|
+
*Ryuta Kamizono*
|
1971
1566
|
|
1972
|
-
|
1567
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
1973
1568
|
|
1974
|
-
|
1975
|
-
`has_and_belongs_to_many` associations *and* on `has_many :through`
|
1976
|
-
associations. Before this change, `before_add` callbacks would be fired
|
1977
|
-
before the record was saved on `has_and_belongs_to_many` associations, but
|
1978
|
-
*not* on `has_many :through` associations.
|
1569
|
+
Fixes #36465.
|
1979
1570
|
|
1980
|
-
|
1571
|
+
*Jeff Doering*
|
1981
1572
|
|
1982
|
-
*
|
1983
|
-
private method defined on its ancestors.
|
1573
|
+
* Add support for multiple databases to `rails db:abort_if_pending_migrations`.
|
1984
1574
|
|
1985
|
-
|
1575
|
+
*Mark Lee*
|
1986
1576
|
|
1987
|
-
|
1577
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
1988
1578
|
|
1989
|
-
*
|
1579
|
+
*Martin R. Schuster*
|
1990
1580
|
|
1991
|
-
|
1581
|
+
* Fix invalid schema when primary key column has a comment.
|
1992
1582
|
|
1993
|
-
|
1994
|
-
book.save!
|
1995
|
-
book.title # => "12345"
|
1583
|
+
Fixes #29966.
|
1996
1584
|
|
1997
|
-
*
|
1585
|
+
*Guilherme Goettems Schneider*
|
1998
1586
|
|
1999
|
-
*
|
2000
|
-
We currently map PostgreSQL ranges to Ruby ranges. This conversion is not fully
|
2001
|
-
possible because the Ruby range does not support excluded beginnings.
|
1587
|
+
* Fix table comment also being applied to the primary key column.
|
2002
1588
|
|
2003
|
-
|
2004
|
-
deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
|
2005
|
-
is not defined) it will raise an `ArgumentException` for ranges with excluding
|
2006
|
-
beginnings.
|
1589
|
+
*Guilherme Goettems Schneider*
|
2007
1590
|
|
2008
|
-
|
1591
|
+
* Allow generated `create_table` migrations to include or skip timestamps.
|
2009
1592
|
|
2010
|
-
*
|
1593
|
+
*Michael Duchemin*
|
2011
1594
|
|
2012
|
-
*Yves Senn*
|
2013
1595
|
|
2014
|
-
Please check [
|
1596
|
+
Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/activerecord/CHANGELOG.md) for previous changes.
|