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