activerecord 4.2.11.3 → 6.0.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +675 -1587
- data/MIT-LICENSE +4 -2
- data/README.rdoc +13 -12
- data/examples/performance.rb +33 -32
- data/examples/simple.rb +5 -4
- data/lib/active_record.rb +41 -22
- data/lib/active_record/aggregations.rb +267 -251
- data/lib/active_record/association_relation.rb +26 -12
- data/lib/active_record/associations.rb +1737 -1597
- data/lib/active_record/associations/alias_tracker.rb +29 -35
- data/lib/active_record/associations/association.rb +133 -58
- data/lib/active_record/associations/association_scope.rb +103 -132
- data/lib/active_record/associations/belongs_to_association.rb +65 -60
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +8 -12
- data/lib/active_record/associations/builder/association.rb +27 -40
- data/lib/active_record/associations/builder/belongs_to.rb +69 -55
- data/lib/active_record/associations/builder/collection_association.rb +10 -33
- data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +52 -66
- data/lib/active_record/associations/builder/has_many.rb +8 -4
- data/lib/active_record/associations/builder/has_one.rb +46 -5
- data/lib/active_record/associations/builder/singular_association.rb +16 -10
- data/lib/active_record/associations/collection_association.rb +136 -288
- data/lib/active_record/associations/collection_proxy.rb +241 -146
- data/lib/active_record/associations/foreign_association.rb +10 -1
- data/lib/active_record/associations/has_many_association.rb +34 -97
- data/lib/active_record/associations/has_many_through_association.rb +60 -87
- data/lib/active_record/associations/has_one_association.rb +61 -49
- data/lib/active_record/associations/has_one_through_association.rb +20 -11
- data/lib/active_record/associations/join_dependency.rb +141 -167
- data/lib/active_record/associations/join_dependency/join_association.rb +38 -86
- data/lib/active_record/associations/join_dependency/join_base.rb +10 -9
- data/lib/active_record/associations/join_dependency/join_part.rb +14 -14
- data/lib/active_record/associations/preloader.rb +90 -92
- data/lib/active_record/associations/preloader/association.rb +90 -123
- data/lib/active_record/associations/preloader/through_association.rb +85 -65
- data/lib/active_record/associations/singular_association.rb +18 -39
- data/lib/active_record/associations/through_association.rb +38 -18
- data/lib/active_record/attribute_assignment.rb +56 -183
- data/lib/active_record/attribute_decorators.rb +39 -15
- data/lib/active_record/attribute_methods.rb +120 -135
- data/lib/active_record/attribute_methods/before_type_cast.rb +13 -8
- data/lib/active_record/attribute_methods/dirty.rb +174 -144
- data/lib/active_record/attribute_methods/primary_key.rb +91 -83
- data/lib/active_record/attribute_methods/query.rb +6 -5
- data/lib/active_record/attribute_methods/read.rb +20 -76
- data/lib/active_record/attribute_methods/serialization.rb +40 -20
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +58 -36
- data/lib/active_record/attribute_methods/write.rb +32 -54
- data/lib/active_record/attributes.rb +214 -82
- data/lib/active_record/autosave_association.rb +96 -38
- data/lib/active_record/base.rb +57 -45
- data/lib/active_record/callbacks.rb +100 -74
- data/lib/active_record/coders/json.rb +3 -1
- data/lib/active_record/coders/yaml_column.rb +24 -12
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +806 -296
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +26 -8
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +238 -115
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +83 -23
- data/lib/active_record/connection_adapters/abstract/quoting.rb +170 -53
- data/lib/active_record/connection_adapters/abstract/savepoints.rb +5 -3
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +74 -46
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +356 -227
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +79 -36
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +664 -243
- data/lib/active_record/connection_adapters/abstract/transaction.rb +191 -83
- data/lib/active_record/connection_adapters/abstract_adapter.rb +469 -202
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +517 -633
- data/lib/active_record/connection_adapters/column.rb +56 -43
- data/lib/active_record/connection_adapters/connection_specification.rb +174 -152
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +29 -0
- data/lib/active_record/connection_adapters/mysql/column.rb +27 -0
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +202 -0
- data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +72 -0
- data/lib/active_record/connection_adapters/mysql/quoting.rb +81 -0
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +72 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +95 -0
- data/lib/active_record/connection_adapters/mysql/schema_dumper.rb +88 -0
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +264 -0
- data/lib/active_record/connection_adapters/mysql/type_metadata.rb +31 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +58 -180
- data/lib/active_record/connection_adapters/postgresql/column.rb +21 -11
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +66 -114
- data/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb +44 -0
- data/lib/active_record/connection_adapters/postgresql/oid.rb +23 -25
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +50 -58
- data/lib/active_record/connection_adapters/postgresql/oid/bit.rb +9 -8
- data/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb +2 -0
- data/lib/active_record/connection_adapters/postgresql/oid/bytea.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/oid/cidr.rb +5 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date.rb +13 -1
- data/lib/active_record/connection_adapters/postgresql/oid/date_time.rb +9 -22
- 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 +31 -19
- 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 -9
- data/lib/active_record/connection_adapters/postgresql/oid/{integer.rb → oid.rb} +6 -2
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +33 -11
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +52 -34
- data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +4 -5
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +58 -54
- data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +10 -5
- data/lib/active_record/connection_adapters/postgresql/oid/vector.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/oid/xml.rb +3 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +144 -47
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +27 -14
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +76 -0
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +178 -108
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +50 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +470 -290
- data/lib/active_record/connection_adapters/postgresql/type_metadata.rb +36 -0
- data/lib/active_record/connection_adapters/postgresql/utils.rb +12 -8
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +555 -356
- data/lib/active_record/connection_adapters/schema_cache.rb +72 -25
- data/lib/active_record/connection_adapters/sql_type_metadata.rb +37 -0
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +120 -0
- data/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb +21 -0
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +103 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +17 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb +19 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +18 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +137 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +294 -345
- data/lib/active_record/connection_adapters/statement_pool.rb +34 -13
- data/lib/active_record/connection_handling.rb +183 -41
- data/lib/active_record/core.rb +253 -229
- data/lib/active_record/counter_cache.rb +67 -49
- data/lib/active_record/database_configurations.rb +233 -0
- data/lib/active_record/database_configurations/database_config.rb +37 -0
- data/lib/active_record/database_configurations/hash_config.rb +50 -0
- data/lib/active_record/database_configurations/url_config.rb +79 -0
- data/lib/active_record/define_callbacks.rb +22 -0
- data/lib/active_record/dynamic_matchers.rb +87 -105
- data/lib/active_record/enum.rb +163 -86
- data/lib/active_record/errors.rb +188 -53
- data/lib/active_record/explain.rb +23 -11
- data/lib/active_record/explain_registry.rb +4 -2
- data/lib/active_record/explain_subscriber.rb +10 -5
- data/lib/active_record/fixture_set/file.rb +35 -9
- 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 +228 -499
- data/lib/active_record/gem_version.rb +6 -4
- data/lib/active_record/inheritance.rb +158 -112
- data/lib/active_record/insert_all.rb +179 -0
- data/lib/active_record/integration.rb +123 -29
- data/lib/active_record/internal_metadata.rb +53 -0
- data/lib/active_record/legacy_yaml_adapter.rb +21 -3
- data/lib/active_record/locale/en.yml +3 -2
- data/lib/active_record/locking/optimistic.rb +87 -96
- data/lib/active_record/locking/pessimistic.rb +18 -6
- data/lib/active_record/log_subscriber.rb +76 -33
- data/lib/active_record/middleware/database_selector.rb +75 -0
- data/lib/active_record/middleware/database_selector/resolver.rb +88 -0
- data/lib/active_record/middleware/database_selector/resolver/session.rb +45 -0
- data/lib/active_record/migration.rb +621 -303
- data/lib/active_record/migration/command_recorder.rb +177 -90
- data/lib/active_record/migration/compatibility.rb +244 -0
- data/lib/active_record/migration/join_table.rb +8 -6
- data/lib/active_record/model_schema.rb +315 -112
- data/lib/active_record/nested_attributes.rb +264 -222
- data/lib/active_record/no_touching.rb +14 -1
- data/lib/active_record/null_relation.rb +24 -37
- data/lib/active_record/persistence.rb +557 -125
- data/lib/active_record/query_cache.rb +19 -23
- data/lib/active_record/querying.rb +43 -29
- data/lib/active_record/railtie.rb +143 -44
- 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 +331 -185
- data/lib/active_record/readonly_attributes.rb +5 -4
- data/lib/active_record/reflection.rb +428 -279
- data/lib/active_record/relation.rb +519 -341
- data/lib/active_record/relation/batches.rb +207 -55
- data/lib/active_record/relation/batches/batch_enumerator.rb +69 -0
- data/lib/active_record/relation/calculations.rb +267 -253
- data/lib/active_record/relation/delegation.rb +70 -80
- data/lib/active_record/relation/finder_methods.rb +286 -241
- data/lib/active_record/relation/from_clause.rb +26 -0
- data/lib/active_record/relation/merger.rb +78 -87
- data/lib/active_record/relation/predicate_builder.rb +114 -119
- data/lib/active_record/relation/predicate_builder/array_handler.rb +27 -26
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +43 -0
- data/lib/active_record/relation/predicate_builder/base_handler.rb +18 -0
- data/lib/active_record/relation/predicate_builder/basic_object_handler.rb +19 -0
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +53 -0
- data/lib/active_record/relation/predicate_builder/range_handler.rb +22 -0
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +7 -1
- data/lib/active_record/relation/query_attribute.rb +50 -0
- data/lib/active_record/relation/query_methods.rb +597 -393
- data/lib/active_record/relation/record_fetch_warning.rb +51 -0
- data/lib/active_record/relation/spawn_methods.rb +11 -13
- data/lib/active_record/relation/where_clause.rb +190 -0
- data/lib/active_record/relation/where_clause_factory.rb +33 -0
- data/lib/active_record/result.rb +79 -42
- data/lib/active_record/runtime_registry.rb +6 -4
- data/lib/active_record/sanitization.rb +144 -121
- data/lib/active_record/schema.rb +21 -24
- data/lib/active_record/schema_dumper.rb +112 -93
- data/lib/active_record/schema_migration.rb +24 -17
- data/lib/active_record/scoping.rb +45 -26
- data/lib/active_record/scoping/default.rb +101 -85
- data/lib/active_record/scoping/named.rb +87 -33
- data/lib/active_record/secure_token.rb +40 -0
- data/lib/active_record/serialization.rb +5 -5
- data/lib/active_record/statement_cache.rb +73 -36
- data/lib/active_record/store.rb +127 -42
- data/lib/active_record/suppressor.rb +61 -0
- data/lib/active_record/table_metadata.rb +75 -0
- data/lib/active_record/tasks/database_tasks.rb +307 -100
- data/lib/active_record/tasks/mysql_database_tasks.rb +55 -99
- data/lib/active_record/tasks/postgresql_database_tasks.rb +81 -41
- data/lib/active_record/tasks/sqlite_database_tasks.rb +38 -16
- data/lib/active_record/test_databases.rb +23 -0
- data/lib/active_record/test_fixtures.rb +225 -0
- data/lib/active_record/timestamp.rb +86 -40
- data/lib/active_record/touch_later.rb +66 -0
- data/lib/active_record/transactions.rb +217 -151
- data/lib/active_record/translation.rb +3 -1
- data/lib/active_record/type.rb +78 -23
- data/lib/active_record/type/adapter_specific_registry.rb +129 -0
- data/lib/active_record/type/date.rb +4 -45
- data/lib/active_record/type/date_time.rb +4 -49
- data/lib/active_record/type/decimal_without_scale.rb +6 -2
- data/lib/active_record/type/hash_lookup_type_map.rb +5 -3
- data/lib/active_record/type/internal/timezone.rb +17 -0
- data/lib/active_record/type/json.rb +30 -0
- data/lib/active_record/type/serialized.rb +24 -15
- data/lib/active_record/type/text.rb +2 -2
- data/lib/active_record/type/time.rb +11 -16
- data/lib/active_record/type/type_map.rb +15 -17
- data/lib/active_record/type/unsigned_integer.rb +9 -7
- data/lib/active_record/type_caster.rb +9 -0
- data/lib/active_record/type_caster/connection.rb +34 -0
- data/lib/active_record/type_caster/map.rb +20 -0
- data/lib/active_record/validations.rb +39 -35
- data/lib/active_record/validations/absence.rb +25 -0
- data/lib/active_record/validations/associated.rb +13 -4
- data/lib/active_record/validations/length.rb +26 -0
- data/lib/active_record/validations/presence.rb +14 -13
- data/lib/active_record/validations/uniqueness.rb +42 -55
- data/lib/active_record/version.rb +3 -1
- data/lib/arel.rb +58 -0
- data/lib/arel/alias_predication.rb +9 -0
- data/lib/arel/attributes.rb +22 -0
- data/lib/arel/attributes/attribute.rb +37 -0
- data/lib/arel/collectors/bind.rb +24 -0
- data/lib/arel/collectors/composite.rb +31 -0
- data/lib/arel/collectors/plain_string.rb +20 -0
- data/lib/arel/collectors/sql_string.rb +20 -0
- data/lib/arel/collectors/substitute_binds.rb +28 -0
- data/lib/arel/crud.rb +42 -0
- data/lib/arel/delete_manager.rb +18 -0
- data/lib/arel/errors.rb +9 -0
- data/lib/arel/expressions.rb +29 -0
- data/lib/arel/factory_methods.rb +49 -0
- data/lib/arel/insert_manager.rb +49 -0
- data/lib/arel/math.rb +45 -0
- data/lib/arel/nodes.rb +68 -0
- data/lib/arel/nodes/and.rb +32 -0
- data/lib/arel/nodes/ascending.rb +23 -0
- data/lib/arel/nodes/binary.rb +52 -0
- data/lib/arel/nodes/bind_param.rb +36 -0
- data/lib/arel/nodes/case.rb +55 -0
- data/lib/arel/nodes/casted.rb +50 -0
- data/lib/arel/nodes/comment.rb +29 -0
- data/lib/arel/nodes/count.rb +12 -0
- data/lib/arel/nodes/delete_statement.rb +45 -0
- data/lib/arel/nodes/descending.rb +23 -0
- data/lib/arel/nodes/equality.rb +18 -0
- data/lib/arel/nodes/extract.rb +24 -0
- data/lib/arel/nodes/false.rb +16 -0
- data/lib/arel/nodes/full_outer_join.rb +8 -0
- data/lib/arel/nodes/function.rb +44 -0
- data/lib/arel/nodes/grouping.rb +8 -0
- data/lib/arel/nodes/in.rb +8 -0
- data/lib/arel/nodes/infix_operation.rb +80 -0
- data/lib/arel/nodes/inner_join.rb +8 -0
- data/lib/arel/nodes/insert_statement.rb +37 -0
- data/lib/arel/nodes/join_source.rb +20 -0
- data/lib/arel/nodes/matches.rb +18 -0
- data/lib/arel/nodes/named_function.rb +23 -0
- data/lib/arel/nodes/node.rb +50 -0
- data/lib/arel/nodes/node_expression.rb +13 -0
- data/lib/arel/nodes/outer_join.rb +8 -0
- data/lib/arel/nodes/over.rb +15 -0
- data/lib/arel/nodes/regexp.rb +16 -0
- data/lib/arel/nodes/right_outer_join.rb +8 -0
- data/lib/arel/nodes/select_core.rb +67 -0
- data/lib/arel/nodes/select_statement.rb +41 -0
- data/lib/arel/nodes/sql_literal.rb +16 -0
- data/lib/arel/nodes/string_join.rb +11 -0
- data/lib/arel/nodes/table_alias.rb +27 -0
- data/lib/arel/nodes/terminal.rb +16 -0
- data/lib/arel/nodes/true.rb +16 -0
- data/lib/arel/nodes/unary.rb +45 -0
- data/lib/arel/nodes/unary_operation.rb +20 -0
- data/lib/arel/nodes/unqualified_column.rb +22 -0
- data/lib/arel/nodes/update_statement.rb +41 -0
- data/lib/arel/nodes/values_list.rb +9 -0
- data/lib/arel/nodes/window.rb +126 -0
- data/lib/arel/nodes/with.rb +11 -0
- data/lib/arel/order_predications.rb +13 -0
- data/lib/arel/predications.rb +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.rb +20 -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/window_predications.rb +9 -0
- data/lib/rails/generators/active_record.rb +7 -5
- data/lib/rails/generators/active_record/application_record/application_record_generator.rb +27 -0
- data/lib/rails/generators/active_record/application_record/templates/application_record.rb.tt +5 -0
- data/lib/rails/generators/active_record/migration.rb +31 -1
- data/lib/rails/generators/active_record/migration/migration_generator.rb +42 -37
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb.tt +24 -0
- data/lib/rails/generators/active_record/migration/templates/{migration.rb → migration.rb.tt} +11 -2
- data/lib/rails/generators/active_record/model/model_generator.rb +19 -22
- data/lib/rails/generators/active_record/model/templates/model.rb.tt +22 -0
- data/lib/rails/generators/active_record/model/templates/{module.rb → module.rb.tt} +0 -0
- metadata +166 -58
- data/lib/active_record/associations/preloader/belongs_to.rb +0 -17
- data/lib/active_record/associations/preloader/collection_association.rb +0 -24
- data/lib/active_record/associations/preloader/has_many.rb +0 -17
- data/lib/active_record/associations/preloader/has_many_through.rb +0 -19
- data/lib/active_record/associations/preloader/has_one.rb +0 -23
- data/lib/active_record/associations/preloader/has_one_through.rb +0 -9
- data/lib/active_record/associations/preloader/singular_association.rb +0 -21
- data/lib/active_record/attribute.rb +0 -163
- data/lib/active_record/attribute_set.rb +0 -81
- data/lib/active_record/attribute_set/builder.rb +0 -106
- data/lib/active_record/connection_adapters/mysql_adapter.rb +0 -498
- data/lib/active_record/connection_adapters/postgresql/array_parser.rb +0 -93
- data/lib/active_record/connection_adapters/postgresql/oid/float.rb +0 -21
- data/lib/active_record/connection_adapters/postgresql/oid/infinity.rb +0 -13
- data/lib/active_record/connection_adapters/postgresql/oid/json.rb +0 -35
- data/lib/active_record/connection_adapters/postgresql/oid/time.rb +0 -11
- data/lib/active_record/railties/jdbcmysql_error.rb +0 -16
- data/lib/active_record/serializers/xml_serializer.rb +0 -193
- data/lib/active_record/type/big_integer.rb +0 -13
- data/lib/active_record/type/binary.rb +0 -50
- data/lib/active_record/type/boolean.rb +0 -31
- data/lib/active_record/type/decimal.rb +0 -64
- data/lib/active_record/type/decorator.rb +0 -14
- data/lib/active_record/type/float.rb +0 -19
- data/lib/active_record/type/integer.rb +0 -59
- data/lib/active_record/type/mutable.rb +0 -16
- data/lib/active_record/type/numeric.rb +0 -36
- data/lib/active_record/type/string.rb +0 -40
- data/lib/active_record/type/time_value.rb +0 -38
- data/lib/active_record/type/value.rb +0 -110
- data/lib/rails/generators/active_record/migration/templates/create_table_migration.rb +0 -19
- data/lib/rails/generators/active_record/model/templates/model.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c3588da1105145a803b938c41fcd2f6053a6c5bb995b6d2b5d5c0692b73a7a9
|
4
|
+
data.tar.gz: 5c57f45f3d17427d3bb55fda6213705e9246f7bb41699990e2b717ea3e165da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ada655dc33878d1ed91b8b5ec035f6c65d0fb6be9b1c92e9f72afc51105a9141a101451584d1c0a7fafefc76d42c7ae4a5349f5eaad18ca69b539f74eed9d2ae
|
7
|
+
data.tar.gz: b285f57dcf0dd6e5b24c4973978e471afd521826c7d62f4e83293827dbf34c1c5d9efa49d87f56d935040bc9ffdc9291eb4d8c5e7a47d8cc5bb281ec4e6c1480
|
data/CHANGELOG.md
CHANGED
@@ -1,2043 +1,1131 @@
|
|
1
|
-
## Rails
|
1
|
+
## Rails 6.0.2.1 (December 18, 2019) ##
|
2
2
|
|
3
3
|
* No changes.
|
4
4
|
|
5
5
|
|
6
|
-
## Rails
|
6
|
+
## Rails 6.0.2 (December 13, 2019) ##
|
7
7
|
|
8
|
-
*
|
9
|
-
|
10
|
-
|
11
|
-
## Rails 4.2.11.1 (March 11, 2019) ##
|
12
|
-
|
13
|
-
* No changes.
|
14
|
-
|
15
|
-
|
16
|
-
## Rails 4.2.11 (November 27, 2018) ##
|
17
|
-
|
18
|
-
* No changes.
|
19
|
-
|
20
|
-
|
21
|
-
## Rails 4.2.10 (September 27, 2017) ##
|
22
|
-
|
23
|
-
* `Relation#joins` is no longer affected by the target model's
|
24
|
-
`current_scope`, with the exception of `unscoped`.
|
8
|
+
* Share the same connection pool for primary and replica databases in the
|
9
|
+
transactional tests for the same database.
|
25
10
|
|
26
|
-
|
11
|
+
*Edouard Chin*
|
27
12
|
|
28
|
-
|
29
|
-
|
30
|
-
## Rails 4.2.9 (June 26, 2017) ##
|
13
|
+
* Fix the preloader when one record is fetched using `after_initialize`
|
14
|
+
but not the entire collection.
|
31
15
|
|
32
|
-
*
|
16
|
+
*Bradley Price*
|
33
17
|
|
34
|
-
|
18
|
+
* Fix collection callbacks not terminating when `:abort` is thrown.
|
35
19
|
|
36
|
-
*
|
20
|
+
*Edouard Chin*, *Ryuta Kamizono*
|
37
21
|
|
38
|
-
|
22
|
+
* Correctly deprecate `where.not` working as NOR for relations.
|
39
23
|
|
40
|
-
|
24
|
+
12a9664 deprecated where.not working as NOR, however
|
25
|
+
doing a relation query like `where.not(relation: { ... })`
|
26
|
+
wouldn't be properly deprecated and `where.not` would work as
|
27
|
+
NAND instead.
|
41
28
|
|
42
|
-
*
|
29
|
+
*Edouard Chin*
|
43
30
|
|
44
|
-
* Fix
|
31
|
+
* Fix `db:migrate` task with multiple databases to restore the connection
|
32
|
+
to the previous database.
|
45
33
|
|
46
|
-
|
34
|
+
The migrate task iterates and establish a connection over each db
|
35
|
+
resulting in the last one to be used by subsequent rake tasks.
|
36
|
+
We should reestablish a connection to the connection that was
|
37
|
+
established before the migrate tasks was run
|
47
38
|
|
48
|
-
*
|
39
|
+
*Edouard Chin*
|
49
40
|
|
50
|
-
|
41
|
+
* Fix multi-threaded issue for `AcceptanceValidator`.
|
51
42
|
|
52
43
|
*Ryuta Kamizono*
|
53
44
|
|
54
|
-
* Make `table_name=` reset current statement cache,
|
55
|
-
so queries are not run against the previous table name.
|
56
|
-
|
57
|
-
*namusyaka*
|
58
|
-
|
59
|
-
|
60
|
-
## Rails 4.2.8 (February 21, 2017) ##
|
61
|
-
|
62
|
-
* Using a mysql2 connection after it fails to reconnect will now have an error message
|
63
|
-
saying the connection is closed rather than an undefined method error message.
|
64
|
-
|
65
|
-
*Dylan Thacker-Smith*
|
66
|
-
|
67
|
-
* Bust Model.attribute_names cache when resetting column information
|
68
|
-
|
69
|
-
*James Coleman*
|
70
|
-
|
71
|
-
* Fix query caching when type information is reset
|
72
|
-
|
73
|
-
Backports ancillary fix in 5.0.
|
74
|
-
|
75
|
-
*James Coleman*
|
76
|
-
|
77
|
-
* Allow `joins` to be unscoped.
|
78
|
-
|
79
|
-
Fixes #13775.
|
80
|
-
|
81
|
-
*Takashi Kokubun*
|
82
|
-
|
83
|
-
* Hashes can once again be passed to setters of `composed_of`, if all of the
|
84
|
-
mapping methods are methods implemented on `Hash`.
|
85
45
|
|
86
|
-
|
46
|
+
## Rails 6.0.1 (November 5, 2019) ##
|
87
47
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
## Rails 4.2.7 (July 12, 2016) ##
|
92
|
-
|
93
|
-
* Inspecting an object with an associated array of over 10 elements no longer
|
94
|
-
truncates the array, preventing `inspect` from looping infinitely in some
|
95
|
-
cases.
|
48
|
+
* Common Table Expressions are allowed on read-only connections.
|
96
49
|
|
97
|
-
|
50
|
+
*Chris Morris*
|
98
51
|
|
99
|
-
*
|
100
|
-
Fixes #25210.
|
52
|
+
* New record instantiation respects `unscope`.
|
101
53
|
|
102
|
-
|
103
|
-
|
104
|
-
* Queries such as `Computer.joins(:monitor).group(:status).count` will now be
|
105
|
-
interpreted as `Computer.joins(:monitor).group('computers.status').count`
|
106
|
-
so that when `Computer` and `Monitor` have both `status` columns we don't
|
107
|
-
have conflicts in projection.
|
54
|
+
*Ryuta Kamizono*
|
108
55
|
|
109
|
-
|
56
|
+
* Fixed a case where `find_in_batches` could halt too early.
|
110
57
|
|
111
|
-
*
|
112
|
-
are specified or an ActiveRecord::StatementInvalid when an invalid type
|
113
|
-
is provided for a column name (e.g. a Hash).
|
58
|
+
*Takayuki Nakata*
|
114
59
|
|
115
|
-
|
60
|
+
* Autosaved associations always perform validations when a custom validation
|
61
|
+
context is used.
|
116
62
|
|
117
|
-
|
63
|
+
*Tekin Suleyman*
|
118
64
|
|
119
|
-
*
|
65
|
+
* `sql.active_record` notifications now include the `:connection` in
|
66
|
+
their payloads.
|
120
67
|
|
121
|
-
|
68
|
+
*Eugene Kenny*
|
122
69
|
|
123
|
-
|
70
|
+
* A rollback encountered in an `after_commit` callback does not reset
|
71
|
+
previously-committed record state.
|
124
72
|
|
73
|
+
*Ryuta Kamizono*
|
125
74
|
|
126
|
-
|
75
|
+
* Fixed that join order was lost when eager-loading.
|
127
76
|
|
128
|
-
*
|
129
|
-
the same table definition would only create one foreign key.
|
77
|
+
*Ryuta Kamizono*
|
130
78
|
|
131
|
-
|
79
|
+
* `DESCRIBE` queries are allowed on read-only connections.
|
132
80
|
|
133
|
-
*
|
134
|
-
clone no longer show as changed attributes in the original object.
|
81
|
+
*Dylan Thacker-Smith*
|
135
82
|
|
136
|
-
|
83
|
+
* Fixed that records that had been `inspect`ed could not be marshaled.
|
137
84
|
|
138
|
-
*
|
85
|
+
*Eugene Kenny*
|
139
86
|
|
140
|
-
|
87
|
+
* The connection pool reaper thread is respawned in forked processes. This
|
88
|
+
fixes that idle connections in forked processes wouldn't be reaped.
|
141
89
|
|
142
|
-
*
|
90
|
+
*John Hawthorn*
|
143
91
|
|
144
|
-
*
|
92
|
+
* The memoized result of `ActiveRecord::Relation#take` is properly cleared
|
93
|
+
when `ActiveRecord::Relation#reset` or `ActiveRecord::Relation#reload`
|
94
|
+
is called.
|
145
95
|
|
146
|
-
|
96
|
+
*Anmol Arora*
|
147
97
|
|
148
|
-
|
98
|
+
* Fixed the performance regression for `primary_keys` introduced MySQL 8.0.
|
149
99
|
|
150
|
-
*
|
151
|
-
These methods determine what relations can be used to back Active Record
|
152
|
-
models (usually tables and views).
|
100
|
+
*Hiroyuki Ishii*
|
153
101
|
|
154
|
-
|
102
|
+
* `insert`, `insert_all`, `upsert`, and `upsert_all` now clear the query cache.
|
155
103
|
|
104
|
+
*Eugene Kenny*
|
156
105
|
|
157
|
-
|
106
|
+
* Call `while_preventing_writes` directly from `connected_to`.
|
158
107
|
|
159
|
-
|
108
|
+
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)`.
|
160
109
|
|
110
|
+
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.
|
161
111
|
|
162
|
-
|
112
|
+
*Eileen M. Uchitelle*
|
163
113
|
|
164
|
-
*
|
114
|
+
* Improve detection of ActiveRecord::StatementTimeout with mysql2 adapter in the edge case when the query is terminated during filesort.
|
165
115
|
|
116
|
+
*Kir Shatrov*
|
166
117
|
|
167
|
-
## Rails 4.2.5 (November 12, 2015) ##
|
168
118
|
|
169
|
-
|
119
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
170
120
|
|
171
|
-
|
121
|
+
* Preserve user supplied joins order as much as possible.
|
172
122
|
|
173
|
-
|
123
|
+
Fixes #36761, #34328, #24281, #12953.
|
174
124
|
|
175
|
-
|
125
|
+
*Ryuta Kamizono*
|
176
126
|
|
177
|
-
|
127
|
+
* Make the DATABASE_URL env variable only affect the primary connection. Add new env variables for multiple databases.
|
178
128
|
|
179
|
-
*
|
180
|
-
standard_conforming_strings setting. Errors were previously disabled because
|
181
|
-
the setting wasn't writable in Postgres 8.1 and didn't exist in earlier
|
182
|
-
versions. Now Rails only supports Postgres 8.2+ we're fine to assume the
|
183
|
-
setting exists. Disabling errors caused problems when using a connection
|
184
|
-
pooling tool like PgBouncer because it's not guaranteed to have the same
|
185
|
-
connection between calls to `execute` and it could leave the connection
|
186
|
-
with errors disabled.
|
129
|
+
*John Crepezzi*, *Eileen Uchitelle*
|
187
130
|
|
188
|
-
|
131
|
+
* Add a warning for enum elements with 'not_' prefix.
|
189
132
|
|
190
|
-
|
133
|
+
class Foo
|
134
|
+
enum status: [:sent, :not_sent]
|
135
|
+
end
|
191
136
|
|
192
|
-
*
|
193
|
-
only instantiates one HABTM object because the join table hasn't a primary key.
|
137
|
+
*Edu Depetris*
|
194
138
|
|
195
|
-
|
139
|
+
* Make currency symbols optional for money column type in PostgreSQL
|
196
140
|
|
197
|
-
|
141
|
+
*Joel Schneider*
|
198
142
|
|
199
|
-
before:
|
200
143
|
|
201
|
-
|
202
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 1
|
144
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
203
145
|
|
204
|
-
|
146
|
+
* Add database_exists? method to connection adapters to check if a database exists.
|
205
147
|
|
206
|
-
|
207
|
-
Project.includes(:salaried_developers).first.salaried_developers.size # => 3
|
148
|
+
*Guilherme Mansur*
|
208
149
|
|
209
|
-
|
150
|
+
* PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute.
|
210
151
|
|
211
|
-
|
152
|
+
Fixes #36022.
|
212
153
|
|
213
|
-
|
154
|
+
*Ryuta Kamizono*
|
214
155
|
|
215
|
-
|
156
|
+
* Make ActiveRecord `ConnectionPool.connections` method thread-safe.
|
216
157
|
|
217
|
-
|
218
|
-
`ActiveRecord::Tasks::DatabaseTasks.migrations_paths` instead of
|
219
|
-
`Migrator.migrations_paths`.
|
158
|
+
Fixes #36465.
|
220
159
|
|
221
|
-
*
|
160
|
+
*Jeff Doering*
|
222
161
|
|
223
|
-
* Fix
|
162
|
+
* Fix sqlite3 collation parsing when using decimal columns.
|
224
163
|
|
225
|
-
|
164
|
+
*Martin R. Schuster*
|
226
165
|
|
227
|
-
|
166
|
+
* Fix invalid schema when primary key column has a comment.
|
228
167
|
|
229
|
-
|
230
|
-
drying up Kernel.system() calls within this namespace and to avoid
|
231
|
-
shell expansion by using a paramter list instead of string as arguments
|
232
|
-
for Kernel.system(). Thanks to Nate Berkopec for supply patch to get
|
233
|
-
test units passing.
|
168
|
+
Fixes #29966.
|
234
169
|
|
235
|
-
*
|
170
|
+
*Guilherme Goettems Schneider*
|
236
171
|
|
237
|
-
*
|
172
|
+
* Fix table comment also being applied to the primary key column.
|
238
173
|
|
239
|
-
|
174
|
+
*Guilherme Goettems Schneider*
|
240
175
|
|
241
|
-
|
176
|
+
* Fix merging left_joins to maintain its own `join_type` context.
|
242
177
|
|
243
|
-
|
244
|
-
to Rails 4.2
|
178
|
+
Fixes #36103.
|
245
179
|
|
246
|
-
*
|
180
|
+
*Ryuta Kamizono*
|
247
181
|
|
248
|
-
* Correctly apply `unscope` when preloading through associations.
|
249
182
|
|
250
|
-
|
183
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
251
184
|
|
252
|
-
*
|
185
|
+
* Add `touch` option to `has_one` association.
|
253
186
|
|
254
|
-
|
187
|
+
*Abhay Nikam*
|
255
188
|
|
256
|
-
|
189
|
+
* Deprecate `where.not` working as NOR and will be changed to NAND in Rails 6.1.
|
257
190
|
|
258
|
-
|
191
|
+
```ruby
|
192
|
+
all = [treasures(:diamond), treasures(:sapphire), cars(:honda), treasures(:sapphire)]
|
193
|
+
assert_equal all, PriceEstimate.all.map(&:estimate_of)
|
194
|
+
```
|
259
195
|
|
260
|
-
|
196
|
+
In Rails 6.0:
|
261
197
|
|
262
|
-
|
263
|
-
|
198
|
+
```ruby
|
199
|
+
sapphire = treasures(:sapphire)
|
264
200
|
|
265
|
-
|
201
|
+
nor = all.reject { |e|
|
202
|
+
e.estimate_of_type == sapphire.class.polymorphic_name
|
203
|
+
}.reject { |e|
|
204
|
+
e.estimate_of_id == sapphire.id
|
205
|
+
}
|
206
|
+
assert_equal [cars(:honda)], nor
|
266
207
|
|
267
|
-
|
208
|
+
without_sapphire = PriceEstimate.where.not(
|
209
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
210
|
+
)
|
211
|
+
assert_equal nor, without_sapphire.map(&:estimate_of)
|
212
|
+
```
|
268
213
|
|
214
|
+
In Rails 6.1:
|
269
215
|
|
270
|
-
|
216
|
+
```ruby
|
217
|
+
sapphire = treasures(:sapphire)
|
271
218
|
|
272
|
-
|
219
|
+
nand = all - [sapphire]
|
220
|
+
assert_equal [treasures(:diamond), cars(:honda)], nand
|
273
221
|
|
274
|
-
|
275
|
-
|
222
|
+
without_sapphire = PriceEstimate.where.not(
|
223
|
+
estimate_of_type: sapphire.class.polymorphic_name, estimate_of_id: sapphire.id
|
224
|
+
)
|
225
|
+
assert_equal nand, without_sapphire.map(&:estimate_of)
|
226
|
+
```
|
276
227
|
|
277
|
-
|
228
|
+
*Ryuta Kamizono*
|
278
229
|
|
279
|
-
|
230
|
+
* Fix dirty tracking after rollback.
|
280
231
|
|
281
|
-
|
282
|
-
the limit: 8 was not coming through. This caused it to become Int[] data type
|
283
|
-
after doing a rebuild off of schema.rb.
|
232
|
+
Fixes #15018, #30167, #33868.
|
284
233
|
|
285
|
-
*
|
234
|
+
*Ryuta Kamizono*
|
286
235
|
|
287
|
-
*
|
236
|
+
* Add `ActiveRecord::Relation#cache_version` to support recyclable cache keys via
|
237
|
+
the versioned entries in `ActiveSupport::Cache`. This also means that
|
238
|
+
`ActiveRecord::Relation#cache_key` will now return a stable key that does not
|
239
|
+
include the max timestamp or count any more.
|
288
240
|
|
289
|
-
|
290
|
-
|
241
|
+
NOTE: This feature is turned off by default, and `cache_key` will still return
|
242
|
+
cache keys with timestamps until you set `ActiveRecord::Base.collection_cache_versioning = true`.
|
243
|
+
That's the setting for all new apps on Rails 6.0+
|
291
244
|
|
292
|
-
|
293
|
-
author.name = nil
|
294
|
-
author.save # => false
|
295
|
-
author.new_record? # => true
|
245
|
+
*Lachlan Sylvester*
|
296
246
|
|
297
|
-
|
247
|
+
* Fix dirty tracking for `touch` to track saved changes.
|
298
248
|
|
299
|
-
|
249
|
+
Fixes #33429.
|
300
250
|
|
301
|
-
*
|
302
|
-
when validating associations.
|
251
|
+
*Ryuta Kamzono*
|
303
252
|
|
304
|
-
|
253
|
+
* `change_column_comment` and `change_table_comment` are invertible only if
|
254
|
+
`to` and `from` options are specified.
|
305
255
|
|
306
|
-
*
|
256
|
+
*Yoshiyuki Kinjo*
|
307
257
|
|
308
|
-
*
|
309
|
-
times.
|
258
|
+
* Don't call commit/rollback callbacks when a record isn't saved.
|
310
259
|
|
311
|
-
Fixes #
|
312
|
-
Fixes #20727.
|
260
|
+
Fixes #29747.
|
313
261
|
|
314
|
-
*
|
262
|
+
*Ryuta Kamizono*
|
315
263
|
|
316
|
-
* `
|
317
|
-
other than `db:migrate`. (eg. `db:rollback`, `db:migrate:dup`, ...)
|
264
|
+
* Fix circular `autosave: true` causes invalid records to be saved.
|
318
265
|
|
319
|
-
|
266
|
+
Prior to the fix, when there was a circular series of `autosave: true`
|
267
|
+
associations, the callback for a `has_many` association was run while
|
268
|
+
another instance of the same callback on the same association hadn't
|
269
|
+
finished running. When control returned to the first instance of the
|
270
|
+
callback, the instance variable had changed, and subsequent associated
|
271
|
+
records weren't saved correctly. Specifically, the ID field for the
|
272
|
+
`belongs_to` corresponding to the `has_many` was `nil`.
|
320
273
|
|
321
|
-
|
274
|
+
Fixes #28080.
|
322
275
|
|
323
|
-
*
|
324
|
-
a wrong type to a namespaced association.
|
276
|
+
*Larry Reid*
|
325
277
|
|
326
|
-
|
278
|
+
* Raise `ArgumentError` for invalid `:limit` and `:precision` like as other options.
|
327
279
|
|
328
|
-
|
280
|
+
Before:
|
329
281
|
|
330
|
-
|
331
|
-
|
282
|
+
```ruby
|
283
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
284
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
285
|
+
add_column :items, :attr3, :integer, limit: 10 # => ActiveRecordError
|
286
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError
|
287
|
+
```
|
332
288
|
|
333
|
-
|
289
|
+
After:
|
334
290
|
|
335
|
-
|
291
|
+
```ruby
|
292
|
+
add_column :items, :attr1, :binary, size: 10 # => ArgumentError
|
293
|
+
add_column :items, :attr2, :decimal, scale: 10 # => ArgumentError
|
294
|
+
add_column :items, :attr3, :integer, limit: 10 # => ArgumentError
|
295
|
+
add_column :items, :attr4, :datetime, precision: 10 # => ArgumentError
|
296
|
+
```
|
336
297
|
|
298
|
+
*Ryuta Kamizono*
|
337
299
|
|
338
|
-
|
300
|
+
* Association loading isn't to be affected by scoping consistently
|
301
|
+
whether preloaded / eager loaded or not, with the exception of `unscoped`.
|
339
302
|
|
340
|
-
|
303
|
+
Before:
|
341
304
|
|
342
|
-
|
305
|
+
```ruby
|
306
|
+
Post.where("1=0").scoping do
|
307
|
+
Comment.find(1).post # => nil
|
308
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
309
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
310
|
+
end
|
311
|
+
```
|
343
312
|
|
344
|
-
|
313
|
+
After:
|
345
314
|
|
346
|
-
|
315
|
+
```ruby
|
316
|
+
Post.where("1=0").scoping do
|
317
|
+
Comment.find(1).post # => #<Post id: 1, ...>
|
318
|
+
Comment.preload(:post).find(1).post # => #<Post id: 1, ...>
|
319
|
+
Comment.eager_load(:post).find(1).post # => #<Post id: 1, ...>
|
320
|
+
end
|
321
|
+
```
|
347
322
|
|
348
|
-
|
349
|
-
`update_attributes` from a getter.
|
323
|
+
Fixes #34638, #35398.
|
350
324
|
|
351
|
-
|
325
|
+
*Ryuta Kamizono*
|
352
326
|
|
353
|
-
|
327
|
+
* Add `rails db:prepare` to migrate or setup a database.
|
354
328
|
|
355
|
-
|
356
|
-
as columns.
|
329
|
+
Runs `db:migrate` if the database exists or `db:setup` if it doesn't.
|
357
330
|
|
358
|
-
|
331
|
+
*Roberto Miranda*
|
359
332
|
|
360
|
-
|
333
|
+
* Add `after_save_commit` callback as shortcut for `after_commit :hook, on: [ :create, :update ]`.
|
361
334
|
|
362
|
-
*
|
335
|
+
*DHH*
|
363
336
|
|
364
|
-
|
337
|
+
* Assign all attributes before calling `build` to ensure the child record is visible in
|
338
|
+
`before_add` and `after_add` callbacks for `has_many :through` associations.
|
365
339
|
|
366
|
-
|
367
|
-
underlying `has_many :through`.
|
340
|
+
Fixes #33249.
|
368
341
|
|
369
|
-
*
|
342
|
+
*Ryan H. Kerr*
|
370
343
|
|
371
|
-
*
|
344
|
+
* Add `ActiveRecord::Relation#extract_associated` for extracting associated records from a relation.
|
372
345
|
|
373
|
-
|
346
|
+
```
|
347
|
+
account.memberships.extract_associated(:user)
|
348
|
+
# => Returns collection of User records
|
349
|
+
```
|
374
350
|
|
375
|
-
*
|
376
|
-
environment. This ensures that initializers are run.
|
351
|
+
*DHH*
|
377
352
|
|
378
|
-
|
353
|
+
* Add `ActiveRecord::Relation#annotate` for adding SQL comments to its queries.
|
379
354
|
|
380
|
-
|
355
|
+
For example:
|
381
356
|
|
382
|
-
|
357
|
+
```
|
358
|
+
Post.where(id: 123).annotate("this is a comment").to_sql
|
359
|
+
# SELECT "posts".* FROM "posts" WHERE "posts"."id" = 123 /* this is a comment */
|
360
|
+
```
|
383
361
|
|
384
|
-
|
385
|
-
`column` definitions for `created_at` and `updated_at` rather than just
|
386
|
-
the first.
|
362
|
+
This can be useful in instrumentation or other analysis of issued queries.
|
387
363
|
|
388
|
-
*
|
364
|
+
*Matt Yoho*
|
389
365
|
|
390
|
-
*
|
366
|
+
* Support Optimizer Hints.
|
391
367
|
|
392
|
-
|
368
|
+
In most databases, a way to control the optimizer is by using optimizer hints,
|
369
|
+
which can be specified within individual statements.
|
393
370
|
|
394
|
-
|
371
|
+
Example (for MySQL):
|
395
372
|
|
396
|
-
|
397
|
-
|
373
|
+
Topic.optimizer_hints("MAX_EXECUTION_TIME(50000)", "NO_INDEX_MERGE(topics)")
|
374
|
+
# SELECT /*+ MAX_EXECUTION_TIME(50000) NO_INDEX_MERGE(topics) */ `topics`.* FROM `topics`
|
398
375
|
|
399
|
-
|
376
|
+
Example (for PostgreSQL with pg_hint_plan):
|
400
377
|
|
401
|
-
|
402
|
-
|
378
|
+
Topic.optimizer_hints("SeqScan(topics)", "Parallel(topics 8)")
|
379
|
+
# SELECT /*+ SeqScan(topics) Parallel(topics 8) */ "topics".* FROM "topics"
|
403
380
|
|
404
|
-
|
381
|
+
See also:
|
405
382
|
|
406
|
-
*
|
383
|
+
* https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html
|
384
|
+
* https://pghintplan.osdn.jp/pg_hint_plan.html
|
385
|
+
* https://docs.oracle.com/en/database/oracle/oracle-database/12.2/tgsql/influencing-the-optimizer.html
|
386
|
+
* https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017
|
387
|
+
* https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/com.ibm.db2.luw.admin.perf.doc/doc/c0070117.html
|
407
388
|
|
408
|
-
*
|
389
|
+
*Ryuta Kamizono*
|
409
390
|
|
410
|
-
|
391
|
+
* Fix query attribute method on user-defined attribute to be aware of typecasted value.
|
411
392
|
|
412
|
-
|
393
|
+
For example, the following code no longer return false as casted non-empty string:
|
413
394
|
|
414
|
-
|
415
|
-
|
395
|
+
```
|
396
|
+
class Post < ActiveRecord::Base
|
397
|
+
attribute :user_defined_text, :text
|
398
|
+
end
|
416
399
|
|
417
|
-
|
400
|
+
Post.new(user_defined_text: "false").user_defined_text? # => true
|
401
|
+
```
|
418
402
|
|
419
|
-
*
|
403
|
+
*Yuji Kamijima*
|
420
404
|
|
421
|
-
*
|
405
|
+
* Quote empty ranges like other empty enumerables.
|
422
406
|
|
423
|
-
|
407
|
+
*Patrick Rebsch*
|
424
408
|
|
425
|
-
|
409
|
+
* Add `insert_all`/`insert_all!`/`upsert_all` methods to `ActiveRecord::Persistence`,
|
410
|
+
allowing bulk inserts akin to the bulk updates provided by `update_all` and
|
411
|
+
bulk deletes by `delete_all`.
|
426
412
|
|
427
|
-
|
428
|
-
|
413
|
+
Supports skipping or upserting duplicates through the `ON CONFLICT` syntax
|
414
|
+
for PostgreSQL (9.5+) and SQLite (3.24+) and `ON DUPLICATE KEY UPDATE` syntax
|
415
|
+
for MySQL.
|
429
416
|
|
430
|
-
|
417
|
+
*Bob Lail*
|
431
418
|
|
432
|
-
|
419
|
+
* Add `rails db:seed:replant` that truncates tables of each database
|
420
|
+
for current environment and loads the seeds.
|
433
421
|
|
434
|
-
*
|
422
|
+
*bogdanvlviv*, *DHH*
|
435
423
|
|
436
|
-
|
424
|
+
* Add `ActiveRecord::Base.connection.truncate` for SQLite3 adapter.
|
437
425
|
|
438
|
-
*
|
439
|
-
That was causing a memory grow problem when creating a lot of records inside a transaction.
|
426
|
+
*bogdanvlviv*
|
440
427
|
|
441
|
-
|
428
|
+
* Deprecate mismatched collation comparison for uniqueness validator.
|
442
429
|
|
443
|
-
|
430
|
+
Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1.
|
431
|
+
To continue case sensitive comparison on the case insensitive column,
|
432
|
+
pass `case_sensitive: true` option explicitly to the uniqueness validator.
|
444
433
|
|
445
|
-
*
|
446
|
-
association when using `where`.
|
434
|
+
*Ryuta Kamizono*
|
447
435
|
|
448
|
-
|
436
|
+
* Add `reselect` method. This is a short-hand for `unscope(:select).select(fields)`.
|
449
437
|
|
450
|
-
|
438
|
+
Fixes #27340.
|
451
439
|
|
440
|
+
*Willian Gustavo Veiga*
|
452
441
|
|
453
|
-
|
442
|
+
* Add negative scopes for all enum values.
|
454
443
|
|
455
|
-
|
444
|
+
Example:
|
456
445
|
|
446
|
+
class Post < ActiveRecord::Base
|
447
|
+
enum status: %i[ drafted active trashed ]
|
448
|
+
end
|
457
449
|
|
458
|
-
|
450
|
+
Post.not_drafted # => where.not(status: :drafted)
|
451
|
+
Post.not_active # => where.not(status: :active)
|
452
|
+
Post.not_trashed # => where.not(status: :trashed)
|
459
453
|
|
460
|
-
*
|
454
|
+
*DHH*
|
461
455
|
|
462
|
-
|
456
|
+
* Fix different `count` calculation when using `size` with manual `select` with DISTINCT.
|
463
457
|
|
464
|
-
|
458
|
+
Fixes #35214.
|
465
459
|
|
466
|
-
*
|
467
|
-
removing the column. This fixes a bug where it was not possible to remove
|
468
|
-
the column on MySQL.
|
460
|
+
*Juani Villarejo*
|
469
461
|
|
470
|
-
Fixes #18664.
|
471
462
|
|
472
|
-
|
463
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
473
464
|
|
474
|
-
*
|
475
|
-
methods. The model and migration generators now use this option, rather than
|
476
|
-
the `add_foreign_key` form.
|
465
|
+
* No changes.
|
477
466
|
|
478
|
-
*Sean Griffin*
|
479
467
|
|
480
|
-
|
468
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
481
469
|
|
482
|
-
|
483
|
-
the precision of timestamp column.
|
470
|
+
* Fix prepared statements caching to be enabled even when query caching is enabled.
|
484
471
|
|
485
472
|
*Ryuta Kamizono*
|
486
473
|
|
487
|
-
*
|
488
|
-
|
489
|
-
The charset of `version` column in `schema_migrations` table is depend
|
490
|
-
on the database default charset and collation rather than the encoding
|
491
|
-
of the connection.
|
474
|
+
* Ensure `update_all` series cares about optimistic locking.
|
492
475
|
|
493
476
|
*Ryuta Kamizono*
|
494
477
|
|
495
|
-
*
|
496
|
-
|
497
|
-
Fixes #18813.
|
498
|
-
|
499
|
-
*Sean Griffin*
|
500
|
-
|
501
|
-
* Fixed several edge cases which could result in a counter cache updating
|
502
|
-
twice or not updating at all for `has_many` and `has_many :through`.
|
503
|
-
|
504
|
-
Fixes #10865.
|
505
|
-
|
506
|
-
*Sean Griffin*
|
507
|
-
|
508
|
-
* Foreign keys added by migrations were given random, generated names. This
|
509
|
-
meant a different `structure.sql` would be generated every time a developer
|
510
|
-
ran migrations on their machine.
|
511
|
-
|
512
|
-
The generated part of foreign key names is now a hash of the table name and
|
513
|
-
column name, which is consistent every time you run the migration.
|
514
|
-
|
515
|
-
*Chris Sinjakli*
|
516
|
-
|
517
|
-
* Fixed ActiveRecord::Relation#group method when argument is SQL reserved key word:
|
518
|
-
|
519
|
-
SplitTest.group(:key).count
|
520
|
-
Property.group(:value).count
|
521
|
-
|
522
|
-
*Bogdan Gusiev*
|
523
|
-
|
524
|
-
* Don't define autosave association callbacks twice from
|
525
|
-
`accepts_nested_attributes_for`.
|
526
|
-
|
527
|
-
Fixes #18704.
|
528
|
-
|
529
|
-
*Sean Griffin*
|
530
|
-
|
531
|
-
* Integer types will no longer raise a `RangeError` when assigning an
|
532
|
-
attribute, but will instead raise when going to the database.
|
533
|
-
|
534
|
-
Fixes several vague issues which were never reported directly. See the
|
535
|
-
commit message from the commit which added this line for some examples.
|
478
|
+
* Don't allow `where` with non numeric string matches to 0 values.
|
536
479
|
|
537
|
-
*
|
538
|
-
|
539
|
-
* Values which would error while being sent to the database (such as an
|
540
|
-
ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
|
541
|
-
assignment. They will still error when sent to the database, but you are
|
542
|
-
given the ability to re-assign it to a valid value.
|
543
|
-
|
544
|
-
Fixes #18580.
|
545
|
-
|
546
|
-
*Sean Griffin*
|
547
|
-
|
548
|
-
* Don't remove join dependencies in `Relation#exists?`
|
549
|
-
|
550
|
-
Fixes #18632.
|
551
|
-
|
552
|
-
*Sean Griffin*
|
553
|
-
|
554
|
-
* Invalid values assigned to a JSON column are assumed to be `nil`.
|
555
|
-
|
556
|
-
Fixes #18629.
|
557
|
-
|
558
|
-
*Sean Griffin*
|
559
|
-
|
560
|
-
* No longer issue deprecation warning when including a scope with extensions.
|
561
|
-
Previously every scope with extension methods was transformed into an
|
562
|
-
instance dependent scope. Including such a scope would wrongfully issue a
|
563
|
-
deprecation warning. This is no longer the case.
|
480
|
+
*Ryuta Kamizono*
|
564
481
|
|
565
|
-
|
482
|
+
* Introduce `ActiveRecord::Relation#destroy_by` and `ActiveRecord::Relation#delete_by`.
|
566
483
|
|
567
|
-
|
484
|
+
`destroy_by` allows relation to find all the records matching the condition and perform
|
485
|
+
`destroy_all` on the matched records.
|
568
486
|
|
569
|
-
|
570
|
-
optimistic locking.
|
487
|
+
Example:
|
571
488
|
|
572
|
-
|
489
|
+
Person.destroy_by(name: 'David')
|
490
|
+
Person.destroy_by(name: 'David', rating: 4)
|
573
491
|
|
574
|
-
|
492
|
+
david = Person.find_by(name: 'David')
|
493
|
+
david.posts.destroy_by(id: [1, 2, 3])
|
575
494
|
|
576
|
-
|
577
|
-
|
495
|
+
`delete_by` allows relation to find all the records matching the condition and perform
|
496
|
+
`delete_all` on the matched records.
|
578
497
|
|
579
|
-
|
498
|
+
Example:
|
580
499
|
|
581
|
-
|
500
|
+
Person.delete_by(name: 'David')
|
501
|
+
Person.delete_by(name: 'David', rating: 4)
|
582
502
|
|
583
|
-
|
503
|
+
david = Person.find_by(name: 'David')
|
504
|
+
david.posts.delete_by(id: [1, 2, 3])
|
584
505
|
|
585
|
-
|
506
|
+
*Abhay Nikam*
|
586
507
|
|
587
|
-
|
588
|
-
is ignored. In 5.6, it's rounded to `2014-08-17 12:30:01`:
|
508
|
+
* Don't allow `where` with invalid value matches to nil values.
|
589
509
|
|
590
|
-
|
510
|
+
Fixes #33624.
|
591
511
|
|
592
512
|
*Ryuta Kamizono*
|
593
513
|
|
594
|
-
*
|
514
|
+
* SQLite3: Implement `add_foreign_key` and `remove_foreign_key`.
|
595
515
|
|
596
516
|
*Ryuta Kamizono*
|
597
517
|
|
598
|
-
*
|
599
|
-
|
600
|
-
*Florian Weingarten*
|
601
|
-
|
602
|
-
* Fixed setting of foreign_key for through associations while building of new record.
|
603
|
-
|
604
|
-
Fixes #12698.
|
605
|
-
|
606
|
-
*Ivan Antropov*
|
607
|
-
|
608
|
-
* Fixed automatic inverse_of for models nested in module.
|
609
|
-
|
610
|
-
*Andrew McCloud*
|
611
|
-
|
612
|
-
* Fix `reaping_frequency` option when the value is a string.
|
613
|
-
|
614
|
-
This usually happens when it is configured using `DATABASE_URL`.
|
615
|
-
|
616
|
-
*korbin*
|
617
|
-
|
618
|
-
* Fix error message when trying to create an associated record and the foreign
|
619
|
-
key is missing.
|
620
|
-
|
621
|
-
Before this fix the following exception was being raised:
|
622
|
-
|
623
|
-
NoMethodError: undefined method `val' for #<Arel::Nodes::BindParam:0x007fc64d19c218>
|
624
|
-
|
625
|
-
Now the message is:
|
626
|
-
|
627
|
-
ActiveRecord::UnknownAttributeError: unknown attribute 'foreign_key' for Model.
|
628
|
-
|
629
|
-
*Rafael Mendonça França*
|
630
|
-
|
631
|
-
* Fix change detection problem for PostgreSQL bytea type and
|
632
|
-
`ArgumentError: string contains null byte` exception with pg-0.18.
|
633
|
-
|
634
|
-
Fixes #17680.
|
635
|
-
|
636
|
-
*Lars Kanis*
|
637
|
-
|
638
|
-
* When a table has a composite primary key, the `primary_key` method for
|
639
|
-
SQLite3 and PostgreSQL adapters was only returning the first field of the key.
|
640
|
-
Ensures that it will return nil instead, as Active Record doesn't support
|
641
|
-
composite primary keys.
|
642
|
-
|
643
|
-
Fixes #18070.
|
644
|
-
|
645
|
-
*arthurnn*
|
646
|
-
|
647
|
-
* Ensure `first!` and friends work on loaded associations.
|
648
|
-
|
649
|
-
Fixes #18237.
|
650
|
-
|
651
|
-
*Sean Griffin*
|
652
|
-
|
653
|
-
* Dump the default `nil` for PostgreSQL UUID primary key.
|
518
|
+
* Deprecate using class level querying methods if the receiver scope
|
519
|
+
regarded as leaked. Use `klass.unscoped` to avoid the leaking scope.
|
654
520
|
|
655
521
|
*Ryuta Kamizono*
|
656
522
|
|
657
|
-
*
|
658
|
-
by the user.
|
659
|
-
|
660
|
-
*Grey Baker*
|
661
|
-
|
662
|
-
* Fixes bug with 'ActiveRecord::Type::Numeric' that causes negative values to
|
663
|
-
be marked as having changed when set to the same negative value.
|
523
|
+
* Allow applications to automatically switch connections.
|
664
524
|
|
665
|
-
|
525
|
+
Adds a middleware and configuration options that can be used in your
|
526
|
+
application to automatically switch between the writing and reading
|
527
|
+
database connections.
|
666
528
|
|
667
|
-
|
529
|
+
`GET` and `HEAD` requests will read from the replica unless there was
|
530
|
+
a write in the last 2 seconds, otherwise they will read from the primary.
|
531
|
+
Non-get requests will always write to the primary. The middleware accepts
|
532
|
+
an argument for a Resolver class and an Operations class where you are able
|
533
|
+
to change how the auto-switcher works to be most beneficial for your
|
534
|
+
application.
|
668
535
|
|
536
|
+
To use the middleware in your application you can use the following
|
537
|
+
configuration options:
|
669
538
|
|
670
|
-
|
539
|
+
```
|
540
|
+
config.active_record.database_selector = { delay: 2.seconds }
|
541
|
+
config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
542
|
+
config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
543
|
+
```
|
671
544
|
|
672
|
-
|
673
|
-
|
674
|
-
`db/schema.rb` now uses `force: :cascade`. This makes it possible to
|
675
|
-
reload the schema when foreign keys are in place.
|
545
|
+
To change the database selection strategy, pass a custom class to the
|
546
|
+
configuration options:
|
676
547
|
|
677
|
-
|
548
|
+
```
|
549
|
+
config.active_record.database_selector = { delay: 10.seconds }
|
550
|
+
config.active_record.database_resolver = MyResolver
|
551
|
+
config.active_record.database_resolver_context = MyResolver::MyCookies
|
552
|
+
```
|
678
553
|
|
679
|
-
*
|
680
|
-
before loading the schema. This is left for the user to do.
|
681
|
-
`db:test:prepare` will still purge the database.
|
554
|
+
*Eileen M. Uchitelle*
|
682
555
|
|
683
|
-
|
684
|
-
|
685
|
-
*Yves Senn*
|
686
|
-
|
687
|
-
* Fix undesirable RangeError by Type::Integer. Add Type::UnsignedInteger.
|
556
|
+
* MySQL: Support `:size` option to change text and blob size.
|
688
557
|
|
689
558
|
*Ryuta Kamizono*
|
690
559
|
|
691
|
-
*
|
692
|
-
|
693
|
-
This option enables to define the column name of associated object's type for polymorphic associations.
|
694
|
-
|
695
|
-
*Ulisses Almeida, Kassio Borges*
|
696
|
-
|
697
|
-
* `add_timestamps` and `remove_timestamps` now properly reversible with
|
698
|
-
options.
|
699
|
-
|
700
|
-
*Noam Gagliardi-Rabinovich*
|
701
|
-
|
702
|
-
* Bring back `db:test:prepare` to synchronize the test database schema.
|
703
|
-
|
704
|
-
Manual synchronization using `bin/rake db:test:prepare` is required
|
705
|
-
when a migration is rolled-back, edited and reapplied.
|
706
|
-
|
707
|
-
`ActiveRecord::Base.maintain_test_schema` now uses `db:test:prepare`
|
708
|
-
to synchronize the schema. Plugins can use this task as a hook to
|
709
|
-
provide custom behavior after the schema has been loaded.
|
710
|
-
|
711
|
-
NOTE: `test:prepare` runs before the schema is synchronized.
|
712
|
-
|
713
|
-
Fixes #17171, #15787.
|
714
|
-
|
715
|
-
*Yves Senn*
|
716
|
-
|
717
|
-
* Change `reflections` public api to return the keys as String objects.
|
718
|
-
|
719
|
-
Fixes #16928.
|
720
|
-
|
721
|
-
*arthurnn*
|
722
|
-
|
723
|
-
* Renaming a table in pg also renames the primary key index.
|
560
|
+
* Make `t.timestamps` with precision by default.
|
724
561
|
|
725
|
-
|
726
|
-
|
727
|
-
*Sean Griffin*
|
728
|
-
|
729
|
-
* Make it possible to access fixtures excluded by a `default_scope`.
|
730
|
-
|
731
|
-
*Yves Senn*
|
732
|
-
|
733
|
-
* Fix preloading of associations with a scope containing joins along with
|
734
|
-
conditions on the joined association.
|
735
|
-
|
736
|
-
*Siddharth Sharma*
|
737
|
-
|
738
|
-
* Add `Table#name` to match `TableDefinition#name`.
|
739
|
-
|
740
|
-
*Cody Cutrer*
|
741
|
-
|
742
|
-
* Cache `CollectionAssociation#reader` proxies separately before and after
|
743
|
-
the owner has been saved so that the proxy is not cached without the
|
744
|
-
owner's id.
|
745
|
-
|
746
|
-
*Ben Woosley*
|
747
|
-
|
748
|
-
* `ActiveRecord::ReadOnlyRecord` now has a descriptive message.
|
749
|
-
|
750
|
-
*Franky W.*
|
751
|
-
|
752
|
-
* Fix preloading of associations which unscope a default scope.
|
753
|
-
|
754
|
-
Fixes #11036.
|
755
|
-
|
756
|
-
*Byron Bischoff*
|
757
|
-
|
758
|
-
* Added SchemaDumper support for tables with jsonb columns.
|
562
|
+
*Ryuta Kamizono*
|
759
563
|
|
760
|
-
*Ted O'Meara*
|
761
564
|
|
762
|
-
|
763
|
-
`Relation` for performing queries and updates is the prefered API.
|
565
|
+
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
764
566
|
|
765
|
-
|
567
|
+
* Remove deprecated `#set_state` from the transaction object.
|
766
568
|
|
767
|
-
*
|
768
|
-
even when using type decorators such as `serialize`.
|
569
|
+
*Rafael Mendonça França*
|
769
570
|
|
770
|
-
|
571
|
+
* Remove deprecated `#supports_statement_cache?` from the database adapters.
|
771
572
|
|
772
|
-
*
|
773
|
-
in an endless loop.
|
573
|
+
*Rafael Mendonça França*
|
774
574
|
|
775
|
-
|
575
|
+
* Remove deprecated `#insert_fixtures` from the database adapters.
|
776
576
|
|
777
|
-
*
|
577
|
+
*Rafael Mendonça França*
|
778
578
|
|
779
|
-
*
|
579
|
+
* Remove deprecated `ActiveRecord::ConnectionAdapters::SQLite3Adapter#valid_alter_table_type?`.
|
780
580
|
|
781
|
-
*
|
581
|
+
*Rafael Mendonça França*
|
782
582
|
|
783
|
-
*
|
583
|
+
* Do not allow passing the column name to `sum` when a block is passed.
|
784
584
|
|
785
|
-
*
|
585
|
+
*Rafael Mendonça França*
|
786
586
|
|
787
|
-
*
|
587
|
+
* Do not allow passing the column name to `count` when a block is passed.
|
788
588
|
|
789
|
-
*
|
589
|
+
*Rafael Mendonça França*
|
790
590
|
|
791
|
-
*
|
591
|
+
* Remove delegation of missing methods in a relation to arel.
|
792
592
|
|
793
|
-
|
794
|
-
# => ActiveRecord::UnknownAttributeError: unknown attribute 'name' for User.
|
593
|
+
*Rafael Mendonça França*
|
795
594
|
|
796
|
-
|
595
|
+
* Remove delegation of missing methods in a relation to private methods of the class.
|
797
596
|
|
798
|
-
*
|
799
|
-
records are autosaved.
|
597
|
+
*Rafael Mendonça França*
|
800
598
|
|
801
|
-
|
599
|
+
* Deprecate `config.active_record.sqlite3.represent_boolean_as_integer`.
|
802
600
|
|
803
|
-
*
|
601
|
+
*Rafael Mendonça França*
|
804
602
|
|
805
|
-
*
|
806
|
-
management middleware.
|
603
|
+
* Change `SQLite3Adapter` to always represent boolean values as integers.
|
807
604
|
|
808
|
-
*
|
605
|
+
*Rafael Mendonça França*
|
809
606
|
|
810
|
-
*
|
607
|
+
* Remove ability to specify a timestamp name for `#cache_key`.
|
811
608
|
|
812
|
-
*
|
609
|
+
*Rafael Mendonça França*
|
813
610
|
|
814
|
-
*
|
611
|
+
* Remove deprecated `ActiveRecord::Migrator.migrations_path=`.
|
815
612
|
|
816
|
-
*
|
613
|
+
*Rafael Mendonça França*
|
817
614
|
|
818
|
-
*
|
615
|
+
* Remove deprecated `expand_hash_conditions_for_aggregates`.
|
819
616
|
|
820
|
-
*
|
617
|
+
*Rafael Mendonça França*
|
821
618
|
|
822
|
-
*
|
823
|
-
outside the schema search path.
|
619
|
+
* Set polymorphic type column to NULL on `dependent: :nullify` strategy.
|
824
620
|
|
825
|
-
|
621
|
+
On polymorphic associations both the foreign key and the foreign type columns will be set to NULL.
|
826
622
|
|
827
|
-
*
|
623
|
+
*Laerti Papa*
|
828
624
|
|
829
|
-
*
|
830
|
-
committing it during the stack unwind. Previously, we could commit half-
|
831
|
-
completed work. This fix only works for Ruby 2.0+; on 1.9, we can't
|
832
|
-
distinguish a thread kill from an ordinary non-local (block) return, so must
|
833
|
-
default to committing.
|
625
|
+
* Allow permitted instance of `ActionController::Parameters` as argument of `ActiveRecord::Relation#exists?`.
|
834
626
|
|
835
|
-
*
|
627
|
+
*Gannon McGibbon*
|
836
628
|
|
837
|
-
*
|
838
|
-
`Comment.where(post_id: Post.none)` returned a non-empty result.
|
629
|
+
* Add support for endless ranges introduces in Ruby 2.6.
|
839
630
|
|
840
|
-
|
631
|
+
*Greg Navis*
|
841
632
|
|
842
|
-
|
633
|
+
* Deprecate passing `migrations_paths` to `connection.assume_migrated_upto_version`.
|
843
634
|
|
844
|
-
*
|
845
|
-
in the future without affecting old migrations that assumed old defaults.
|
635
|
+
*Ryuta Kamizono*
|
846
636
|
|
847
|
-
|
637
|
+
* MySQL: `ROW_FORMAT=DYNAMIC` create table option by default.
|
848
638
|
|
849
|
-
|
639
|
+
Since MySQL 5.7.9, the `innodb_default_row_format` option defines the default row
|
640
|
+
format for InnoDB tables. The default setting is `DYNAMIC`.
|
641
|
+
The row format is required for indexing on `varchar(255)` with `utf8mb4` columns.
|
850
642
|
|
851
|
-
*
|
643
|
+
*Ryuta Kamizono*
|
852
644
|
|
853
|
-
*
|
645
|
+
* Fix join table column quoting with SQLite.
|
854
646
|
|
855
|
-
*
|
647
|
+
*Gannon McGibbon*
|
856
648
|
|
857
|
-
*
|
649
|
+
* Allow disabling scopes generated by `ActiveRecord.enum`.
|
858
650
|
|
859
|
-
*
|
651
|
+
*Alfred Dominic*
|
860
652
|
|
861
|
-
*
|
862
|
-
has support for SQL views. Connection adapters should define this method.
|
653
|
+
* Ensure that `delete_all` on collection proxy returns affected count.
|
863
654
|
|
864
|
-
*
|
655
|
+
*Ryuta Kamizono*
|
865
656
|
|
866
|
-
*
|
657
|
+
* Reset scope after delete on collection association to clear stale offsets of removed records.
|
867
658
|
|
868
|
-
|
659
|
+
*Gannon McGibbon*
|
869
660
|
|
870
|
-
|
661
|
+
* Add the ability to prevent writes to a database for the duration of a block.
|
871
662
|
|
872
|
-
|
873
|
-
|
663
|
+
Allows the application to prevent writes to a database. This can be useful when
|
664
|
+
you're building out multiple databases and want to make sure you're not sending
|
665
|
+
writes when you want a read.
|
874
666
|
|
875
|
-
|
667
|
+
If `while_preventing_writes` is called and the query is considered a write
|
668
|
+
query the database will raise an exception regardless of whether the database
|
669
|
+
user is able to write.
|
876
670
|
|
877
|
-
|
671
|
+
This is not meant to be a catch-all for write queries but rather a way to enforce
|
672
|
+
read-only queries without opening a second connection. One purpose of this is to
|
673
|
+
catch accidental writes, not all writes.
|
878
674
|
|
879
|
-
*
|
675
|
+
*Eileen M. Uchitelle*
|
880
676
|
|
881
|
-
|
882
|
-
database.yml. Otherwise, `SET NAMES utf8mb4` will use the default
|
883
|
-
collation for that charset (utf8mb4_general_ci) when you may have chosen
|
884
|
-
a different collation, like utf8mb4_unicode_ci.
|
677
|
+
* Allow aliased attributes to be used in `#update_columns` and `#update`.
|
885
678
|
|
886
|
-
|
887
|
-
is unlikely to affect you.
|
679
|
+
*Gannon McGibbon*
|
888
680
|
|
889
|
-
|
681
|
+
* Allow spaces in postgres table names.
|
890
682
|
|
891
|
-
|
683
|
+
Fixes issue where "user post" is misinterpreted as "\"user\".\"post\"" when quoting table names with the postgres adapter.
|
892
684
|
|
893
|
-
*
|
685
|
+
*Gannon McGibbon*
|
894
686
|
|
895
|
-
*
|
896
|
-
PostgreSQL.
|
687
|
+
* Cached `columns_hash` fields should be excluded from `ResultSet#column_types`.
|
897
688
|
|
898
|
-
|
689
|
+
PR #34528 addresses the inconsistent behaviour when attribute is defined for an ignored column. The following test
|
690
|
+
was passing for SQLite and MySQL, but failed for PostgreSQL:
|
899
691
|
|
900
|
-
|
692
|
+
```ruby
|
693
|
+
class DeveloperName < ActiveRecord::Type::String
|
694
|
+
def deserialize(value)
|
695
|
+
"Developer: #{value}"
|
696
|
+
end
|
697
|
+
end
|
901
698
|
|
902
|
-
|
903
|
-
|
699
|
+
class AttributedDeveloper < ActiveRecord::Base
|
700
|
+
self.table_name = "developers"
|
904
701
|
|
905
|
-
|
702
|
+
attribute :name, DeveloperName.new
|
906
703
|
|
907
|
-
|
704
|
+
self.ignored_columns += ["name"]
|
705
|
+
end
|
908
706
|
|
909
|
-
|
707
|
+
developer = AttributedDeveloper.create
|
708
|
+
developer.update_column :name, "name"
|
910
709
|
|
911
|
-
|
710
|
+
loaded_developer = AttributedDeveloper.where(id: developer.id).select("*").first
|
711
|
+
puts loaded_developer.name # should be "Developer: name" but it's just "name"
|
712
|
+
```
|
912
713
|
|
913
|
-
*
|
714
|
+
*Dmitry Tsepelev*
|
914
715
|
|
915
|
-
*
|
916
|
-
`after_rollback`/`after_create` callbacks and prints them to the logs.
|
917
|
-
Future versions of Rails will not rescue these errors anymore and
|
918
|
-
just bubble them up like the other callbacks.
|
716
|
+
* Make the implicit order column configurable.
|
919
717
|
|
920
|
-
|
718
|
+
When calling ordered finder methods such as `first` or `last` without an
|
719
|
+
explicit order clause, ActiveRecord sorts records by primary key. This can
|
720
|
+
result in unpredictable and surprising behaviour when the primary key is
|
721
|
+
not an auto-incrementing integer, for example when it's a UUID. This change
|
722
|
+
makes it possible to override the column used for implicit ordering such
|
723
|
+
that `first` and `last` will return more predictable results.
|
921
724
|
|
922
725
|
Example:
|
923
726
|
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
Fixes #13460.
|
727
|
+
class Project < ActiveRecord::Base
|
728
|
+
self.implicit_order_column = "created_at"
|
729
|
+
end
|
928
730
|
|
929
|
-
*
|
731
|
+
*Tekin Suleyman*
|
930
732
|
|
931
|
-
*
|
932
|
-
`enum`) with the same name as a global method are incorrectly overridden
|
933
|
-
when subclassing.
|
733
|
+
* Bump minimum PostgreSQL version to 9.3.
|
934
734
|
|
935
|
-
|
735
|
+
*Yasuo Honda*
|
936
736
|
|
937
|
-
|
737
|
+
* Values of enum are frozen, raising an error when attempting to modify them.
|
938
738
|
|
939
|
-
*
|
940
|
-
well.
|
739
|
+
*Emmanuel Byrd*
|
941
740
|
|
942
|
-
|
741
|
+
* Move `ActiveRecord::StatementInvalid` SQL to error property and include binds as separate error property.
|
943
742
|
|
944
|
-
|
743
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception_class` now requires `binds` to be passed as the last argument.
|
945
744
|
|
946
|
-
|
745
|
+
`ActiveRecord::ConnectionAdapters::AbstractAdapter#translate_exception` now requires `message`, `sql`, and `binds` to be passed as keyword arguments.
|
947
746
|
|
948
|
-
|
747
|
+
Subclasses of `ActiveRecord::StatementInvalid` must now provide `sql:` and `binds:` arguments to `super`.
|
949
748
|
|
950
|
-
|
749
|
+
Example:
|
951
750
|
|
952
|
-
|
751
|
+
```
|
752
|
+
class MySubclassedError < ActiveRecord::StatementInvalid
|
753
|
+
def initialize(message, sql:, binds:)
|
754
|
+
super(message, sql: sql, binds: binds)
|
755
|
+
end
|
756
|
+
end
|
757
|
+
```
|
953
758
|
|
954
|
-
*
|
759
|
+
*Gannon McGibbon*
|
955
760
|
|
956
|
-
*
|
761
|
+
* Add an `:if_not_exists` option to `create_table`.
|
957
762
|
|
958
763
|
Example:
|
959
764
|
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
964
|
-
index_exists? :articles, :body, name: "idx_title" # => `true`
|
965
|
-
|
966
|
-
# After:
|
967
|
-
index_exists? :articles, :title, name: "idx_title" # => `true`
|
968
|
-
index_exists? :articles, :body, name: "idx_title" # => `false`
|
969
|
-
|
970
|
-
*Yves Senn*, *Matthew Draper*
|
765
|
+
create_table :posts, if_not_exists: true do |t|
|
766
|
+
t.string :title
|
767
|
+
end
|
971
768
|
|
972
|
-
|
973
|
-
Not passing the option is deprecated but the default is still `null: true`.
|
974
|
-
With Rails 5 this will change to `null: false`.
|
769
|
+
That would execute:
|
975
770
|
|
976
|
-
|
771
|
+
CREATE TABLE IF NOT EXISTS posts (
|
772
|
+
...
|
773
|
+
)
|
977
774
|
|
978
|
-
|
979
|
-
|
980
|
-
destroyed.
|
775
|
+
If the table already exists, `if_not_exists: false` (the default) raises an
|
776
|
+
exception whereas `if_not_exists: true` does nothing.
|
981
777
|
|
982
|
-
*
|
778
|
+
*fatkodima*, *Stefan Kanev*
|
983
779
|
|
984
|
-
*
|
780
|
+
* Defining an Enum as a Hash with blank key, or as an Array with a blank value, now raises an `ArgumentError`.
|
985
781
|
|
986
|
-
|
987
|
-
Active Record will return the current value of the primary key. This
|
988
|
-
makes it impossible to correctly do an update operation if you change the
|
989
|
-
id.
|
782
|
+
*Christophe Maximin*
|
990
783
|
|
991
|
-
|
784
|
+
* Adds support for multiple databases to `rails db:schema:cache:dump` and `rails db:schema:cache:clear`.
|
992
785
|
|
993
|
-
*
|
786
|
+
*Gannon McGibbon*
|
994
787
|
|
995
|
-
*
|
996
|
-
|
997
|
-
require the `configuration` to act on as an argument.
|
788
|
+
* `update_columns` now correctly raises `ActiveModel::MissingAttributeError`
|
789
|
+
if the attribute does not exist.
|
998
790
|
|
999
|
-
*
|
791
|
+
*Sean Griffin*
|
1000
792
|
|
1001
|
-
*
|
1002
|
-
schema format.
|
793
|
+
* Add support for hash and URL configs in database hash of `ActiveRecord::Base.connected_to`.
|
1003
794
|
|
1004
|
-
|
795
|
+
````
|
796
|
+
User.connected_to(database: { writing: "postgres://foo" }) do
|
797
|
+
User.create!(name: "Gannon")
|
798
|
+
end
|
1005
799
|
|
1006
|
-
|
800
|
+
config = { "adapter" => "sqlite3", "database" => "db/readonly.sqlite3" }
|
801
|
+
User.connected_to(database: { reading: config }) do
|
802
|
+
User.count
|
803
|
+
end
|
804
|
+
````
|
1007
805
|
|
1008
|
-
*
|
806
|
+
*Gannon McGibbon*
|
1009
807
|
|
1010
|
-
|
808
|
+
* Support default expression for MySQL.
|
1011
809
|
|
1012
|
-
|
810
|
+
MySQL 8.0.13 and higher supports default value to be a function or expression.
|
1013
811
|
|
1014
|
-
|
1015
|
-
source so it has been deprecated. Code that used `source_macro`
|
1016
|
-
was removed in #16353.
|
812
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-table.html
|
1017
813
|
|
1018
|
-
*
|
814
|
+
*Ryuta Kamizono*
|
1019
815
|
|
1020
|
-
*
|
816
|
+
* Support expression indexes for MySQL.
|
1021
817
|
|
1022
|
-
|
818
|
+
MySQL 8.0.13 and higher supports functional key parts that index
|
819
|
+
expression values rather than column or column prefix values.
|
1023
820
|
|
1024
|
-
|
821
|
+
https://dev.mysql.com/doc/refman/8.0/en/create-index.html
|
1025
822
|
|
1026
|
-
*
|
823
|
+
*Ryuta Kamizono*
|
1027
824
|
|
1028
|
-
|
825
|
+
* Fix collection cache key with limit and custom select to avoid ambiguous timestamp column error.
|
1029
826
|
|
1030
|
-
|
1031
|
-
t.jsonb :meta_data
|
1032
|
-
end
|
827
|
+
Fixes #33056.
|
1033
828
|
|
1034
|
-
*
|
829
|
+
*Federico Martinez*
|
1035
830
|
|
1036
|
-
*
|
831
|
+
* Add basic API for connection switching to support multiple databases.
|
1037
832
|
|
1038
|
-
|
833
|
+
1) Adds a `connects_to` method for models to connect to multiple databases. Example:
|
1039
834
|
|
1040
|
-
|
1041
|
-
|
835
|
+
```
|
836
|
+
class AnimalsModel < ApplicationRecord
|
837
|
+
self.abstract_class = true
|
1042
838
|
|
1043
|
-
|
839
|
+
connects_to database: { writing: :animals_primary, reading: :animals_replica }
|
840
|
+
end
|
1044
841
|
|
1045
|
-
|
842
|
+
class Dog < AnimalsModel
|
843
|
+
# connected to both the animals_primary db for writing and the animals_replica for reading
|
844
|
+
end
|
845
|
+
```
|
1046
846
|
|
1047
|
-
|
1048
|
-
|
847
|
+
2) Adds a `connected_to` block method for switching connection roles or connecting to
|
848
|
+
a database that the model didn't connect to. Connecting to the database in this block is
|
849
|
+
useful when you have another defined connection, for example `slow_replica` that you don't
|
850
|
+
want to connect to by default but need in the console, or a specific code block.
|
1049
851
|
|
1050
|
-
|
852
|
+
```
|
853
|
+
ActiveRecord::Base.connected_to(role: :reading) do
|
854
|
+
Dog.first # finds dog from replica connected to AnimalsBase
|
855
|
+
Book.first # doesn't have a reading connection, will raise an error
|
856
|
+
end
|
857
|
+
```
|
1051
858
|
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
859
|
+
```
|
860
|
+
ActiveRecord::Base.connected_to(database: :slow_replica) do
|
861
|
+
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
|
862
|
+
end
|
863
|
+
```
|
1055
864
|
|
1056
|
-
*
|
865
|
+
*Eileen M. Uchitelle*
|
1057
866
|
|
1058
|
-
*
|
1059
|
-
This matches the existing behavior of HABTM associations.
|
867
|
+
* Enum raises on invalid definition values
|
1060
868
|
|
1061
|
-
|
869
|
+
When defining a Hash enum it can be easy to use `[]` instead of `{}`. This
|
870
|
+
commit checks that only valid definition values are provided, those can
|
871
|
+
be a Hash, an array of Symbols or an array of Strings. Otherwise it
|
872
|
+
raises an `ArgumentError`.
|
1062
873
|
|
1063
|
-
|
874
|
+
Fixes #33961
|
1064
875
|
|
1065
|
-
*
|
1066
|
-
a class.
|
876
|
+
*Alberto Almagro*
|
1067
877
|
|
1068
|
-
|
878
|
+
* Reloading associations now clears the Query Cache like `Persistence#reload` does.
|
1069
879
|
|
1070
|
-
|
880
|
+
```
|
881
|
+
class Post < ActiveRecord::Base
|
882
|
+
has_one :category
|
883
|
+
belongs_to :author
|
884
|
+
has_many :comments
|
885
|
+
end
|
1071
886
|
|
1072
|
-
|
887
|
+
# Each of the following will now clear the query cache.
|
888
|
+
post.reload_category
|
889
|
+
post.reload_author
|
890
|
+
post.comments.reload
|
891
|
+
```
|
1073
892
|
|
1074
|
-
*
|
893
|
+
*Christophe Maximin*
|
1075
894
|
|
1076
|
-
|
1077
|
-
|
895
|
+
* Added `index` option for `change_table` migration helpers.
|
896
|
+
With this change you can create indexes while adding new
|
897
|
+
columns into the existing tables.
|
1078
898
|
|
1079
899
|
Example:
|
1080
900
|
|
1081
|
-
|
1082
|
-
|
1083
|
-
end
|
1084
|
-
|
1085
|
-
class Comment
|
1086
|
-
include ActiveModel::Model
|
1087
|
-
attr_accessor :category, :text
|
901
|
+
change_table(:languages) do |t|
|
902
|
+
t.string :country_code, index: true
|
1088
903
|
end
|
1089
904
|
|
1090
|
-
|
1091
|
-
post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.")
|
1092
|
-
post.save!
|
1093
|
-
|
1094
|
-
# 4.0
|
1095
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1096
|
-
|
1097
|
-
# 4.1 before
|
1098
|
-
post.comment # => "#<Comment:0x007f80ab48ff98>"
|
1099
|
-
|
1100
|
-
# 4.1 after
|
1101
|
-
post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
|
1102
|
-
|
1103
|
-
When using `JSON` as the coder in `serialize`, Active Record will use the
|
1104
|
-
new `ActiveRecord::Coders::JSON` coder which delegates its `dump/load` to
|
1105
|
-
`ActiveSupport::JSON.encode/decode`. This ensures special objects are dumped
|
1106
|
-
correctly using the `#as_json` hook.
|
1107
|
-
|
1108
|
-
To keep the previous behaviour, supply a custom coder instead
|
1109
|
-
([example](https://gist.github.com/jenncoop/8c4142bbe59da77daa63)).
|
1110
|
-
|
1111
|
-
Fixes #15594.
|
1112
|
-
|
1113
|
-
*Jenn Cooper*
|
1114
|
-
|
1115
|
-
* Do not use `RENAME INDEX` syntax for MariaDB 10.0.
|
1116
|
-
|
1117
|
-
Fixes #15931.
|
1118
|
-
|
1119
|
-
*Jeff Browning*
|
1120
|
-
|
1121
|
-
* Calling `#empty?` on a `has_many` association would use the value from the
|
1122
|
-
counter cache if one exists.
|
905
|
+
*Mehmet Emin İNAÇ*
|
1123
906
|
|
1124
|
-
|
907
|
+
* Fix `transaction` reverting for migrations.
|
1125
908
|
|
1126
|
-
|
1127
|
-
|
909
|
+
Before: Commands inside a `transaction` in a reverted migration ran uninverted.
|
910
|
+
Now: This change fixes that by reverting commands inside `transaction` block.
|
1128
911
|
|
1129
|
-
|
912
|
+
*fatkodima*, *David Verhasselt*
|
1130
913
|
|
1131
|
-
|
914
|
+
* Raise an error instead of scanning the filesystem root when `fixture_path` is blank.
|
1132
915
|
|
1133
|
-
*
|
1134
|
-
produce an `IN` statements.
|
916
|
+
*Gannon McGibbon*, *Max Albrecht*
|
1135
917
|
|
1136
|
-
|
918
|
+
* Allow `ActiveRecord::Base.configurations=` to be set with a symbolized hash.
|
1137
919
|
|
1138
|
-
|
1139
|
-
"categorizations"."category_id" = 1 AND "categorizations"."id" IN (1, 2)
|
920
|
+
*Gannon McGibbon*
|
1140
921
|
|
1141
|
-
|
922
|
+
* Don't update counter cache unless the record is actually saved.
|
1142
923
|
|
1143
|
-
|
1144
|
-
"categorizations"."category_id" = 1
|
924
|
+
Fixes #31493, #33113, #33117.
|
1145
925
|
|
1146
|
-
*
|
926
|
+
*Ryuta Kamizono*
|
1147
927
|
|
1148
|
-
*
|
1149
|
-
values for string columns. Otherwise, in some database, the string column
|
1150
|
-
values will be coerced to a numeric allowing false or 0.seconds match any
|
1151
|
-
string starting with a non-digit.
|
928
|
+
* Deprecate `ActiveRecord::Result#to_hash` in favor of `ActiveRecord::Result#to_a`.
|
1152
929
|
|
1153
|
-
|
930
|
+
*Gannon McGibbon*, *Kevin Cheng*
|
1154
931
|
|
1155
|
-
|
932
|
+
* SQLite3 adapter supports expression indexes.
|
1156
933
|
|
1157
|
-
|
934
|
+
```
|
935
|
+
create_table :users do |t|
|
936
|
+
t.string :email
|
937
|
+
end
|
1158
938
|
|
1159
|
-
|
1160
|
-
|
939
|
+
add_index :users, 'lower(email)', name: 'index_users_on_email', unique: true
|
940
|
+
```
|
1161
941
|
|
1162
|
-
*
|
942
|
+
*Gray Kemmey*
|
1163
943
|
|
1164
|
-
*
|
1165
|
-
(Call to `count` generated invalid SQL.)
|
944
|
+
* Allow subclasses to redefine autosave callbacks for associated records.
|
1166
945
|
|
1167
|
-
|
946
|
+
Fixes #33305.
|
1168
947
|
|
1169
|
-
*
|
948
|
+
*Andrey Subbota*
|
1170
949
|
|
1171
|
-
|
950
|
+
* Bump minimum MySQL version to 5.5.8.
|
1172
951
|
|
1173
|
-
*
|
952
|
+
*Yasuo Honda*
|
1174
953
|
|
1175
|
-
*
|
954
|
+
* Use MySQL utf8mb4 character set by default.
|
1176
955
|
|
1177
|
-
|
956
|
+
`utf8mb4` character set with 4-Byte encoding supports supplementary characters including emoji.
|
957
|
+
The previous default 3-Byte encoding character set `utf8` is not enough to support them.
|
1178
958
|
|
1179
|
-
*
|
1180
|
-
from `before_destroy` to `after_destroy` callback chain
|
959
|
+
*Yasuo Honda*
|
1181
960
|
|
1182
|
-
|
961
|
+
* Fix duplicated record creation when using nested attributes with `create_with`.
|
1183
962
|
|
1184
|
-
*
|
963
|
+
*Darwin Wu*
|
1185
964
|
|
1186
|
-
*
|
965
|
+
* Configuration item `config.filter_parameters` could also filter out
|
966
|
+
sensitive values of database columns when calling `#inspect`.
|
967
|
+
We also added `ActiveRecord::Base::filter_attributes`/`=` in order to
|
968
|
+
specify sensitive attributes to specific model.
|
1187
969
|
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
970
|
+
```
|
971
|
+
Rails.application.config.filter_parameters += [:credit_card_number, /phone/]
|
972
|
+
Account.last.inspect # => #<Account id: 123, name: "DHH", credit_card_number: [FILTERED], telephone_number: [FILTERED] ...>
|
973
|
+
SecureAccount.filter_attributes += [:name]
|
974
|
+
SecureAccount.last.inspect # => #<SecureAccount id: 42, name: [FILTERED], credit_card_number: [FILTERED] ...>
|
975
|
+
```
|
1191
976
|
|
1192
|
-
|
977
|
+
*Zhang Kang*, *Yoshiyuki Kinjo*
|
1193
978
|
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
user.save
|
1198
|
-
user.reload.name # => "Sean Griffin"
|
979
|
+
* Deprecate `column_name_length`, `table_name_length`, `columns_per_table`,
|
980
|
+
`indexes_per_table`, `columns_per_multicolumn_index`, `sql_query_length`,
|
981
|
+
and `joins_per_query` methods in `DatabaseLimits`.
|
1199
982
|
|
1200
|
-
|
983
|
+
*Ryuta Kamizono*
|
1201
984
|
|
1202
|
-
|
1203
|
-
user.name << ' Griffin'
|
1204
|
-
user.save
|
1205
|
-
user.reload.name # => "Sean Griffin"
|
985
|
+
* `ActiveRecord::Base.configurations` now returns an object.
|
1206
986
|
|
1207
|
-
|
987
|
+
`ActiveRecord::Base.configurations` used to return a hash, but this
|
988
|
+
is an inflexible data model. In order to improve multiple-database
|
989
|
+
handling in Rails, we've changed this to return an object. Some methods
|
990
|
+
are provided to make the object behave hash-like in order to ease the
|
991
|
+
transition process. Since most applications don't manipulate the hash
|
992
|
+
we've decided to add backwards-compatible functionality that will throw
|
993
|
+
a deprecation warning if used, however calling `ActiveRecord::Base.configurations`
|
994
|
+
will use the new version internally and externally.
|
1208
995
|
|
1209
|
-
|
1210
|
-
is invalid.
|
996
|
+
For example, the following `database.yml`:
|
1211
997
|
|
1212
|
-
|
998
|
+
```
|
999
|
+
development:
|
1000
|
+
adapter: sqlite3
|
1001
|
+
database: db/development.sqlite3
|
1002
|
+
```
|
1213
1003
|
|
1214
|
-
|
1215
|
-
a part of `schema.rb`. This is supported by Mysql2Adapter, MysqlAdapter
|
1216
|
-
and PostgreSQLAdapter.
|
1004
|
+
Used to become a hash:
|
1217
1005
|
|
1218
|
-
|
1219
|
-
|
1006
|
+
```
|
1007
|
+
{ "development" => { "adapter" => "sqlite3", "database" => "db/development.sqlite3" } }
|
1008
|
+
```
|
1220
1009
|
|
1221
|
-
|
1010
|
+
Is now converted into the following object:
|
1222
1011
|
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1012
|
+
```
|
1013
|
+
#<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[
|
1014
|
+
#<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",
|
1015
|
+
@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>
|
1016
|
+
]
|
1017
|
+
```
|
1226
1018
|
|
1227
|
-
|
1019
|
+
Iterating over the database configurations has also changed. Instead of
|
1020
|
+
calling hash methods on the `configurations` hash directly, a new method `configs_for` has
|
1021
|
+
been provided that allows you to select the correct configuration. `env_name` and
|
1022
|
+
`spec_name` arguments are optional. For example, these return an array of
|
1023
|
+
database config objects for the requested environment and a single database config object
|
1024
|
+
will be returned for the requested environment and specification name respectively.
|
1228
1025
|
|
1229
|
-
|
1230
|
-
|
1026
|
+
```
|
1027
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development")
|
1028
|
+
ActiveRecord::Base.configurations.configs_for(env_name: "development", spec_name: "primary")
|
1029
|
+
```
|
1231
1030
|
|
1232
|
-
*
|
1031
|
+
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1233
1032
|
|
1234
|
-
*
|
1235
|
-
broken and inconsistent.
|
1033
|
+
* Add database configuration to disable advisory locks.
|
1236
1034
|
|
1237
|
-
|
1035
|
+
```
|
1036
|
+
production:
|
1037
|
+
adapter: postgresql
|
1038
|
+
advisory_locks: false
|
1039
|
+
```
|
1238
1040
|
|
1239
|
-
*
|
1041
|
+
*Guo Xiang*
|
1240
1042
|
|
1241
|
-
|
1043
|
+
* SQLite3 adapter `alter_table` method restores foreign keys.
|
1242
1044
|
|
1243
|
-
*
|
1045
|
+
*Yasuo Honda*
|
1244
1046
|
|
1245
|
-
*
|
1246
|
-
would fail numericality validation, regardless of the old value. Previously
|
1247
|
-
this would only occur if the old value was 0.
|
1047
|
+
* Allow `:to_table` option to `invert_remove_foreign_key`.
|
1248
1048
|
|
1249
1049
|
Example:
|
1250
1050
|
|
1251
|
-
|
1252
|
-
model.number = '5wibble'
|
1253
|
-
model.number_changed? # => true
|
1254
|
-
|
1255
|
-
Fixes #14731.
|
1051
|
+
remove_foreign_key :accounts, to_table: :owners
|
1256
1052
|
|
1257
|
-
*
|
1053
|
+
*Nikolay Epifanov*, *Rich Chen*
|
1258
1054
|
|
1259
|
-
*
|
1260
|
-
|
1261
|
-
as it would be with `Model.find(model.id)`.
|
1055
|
+
* Add environment & load_config dependency to `bin/rake db:seed` to enable
|
1056
|
+
seed load in environments without Rails and custom DB configuration
|
1262
1057
|
|
1263
|
-
*
|
1058
|
+
*Tobias Bielohlawek*
|
1264
1059
|
|
1265
|
-
*
|
1266
|
-
If this is not the case a `NoMethodError` is raised.
|
1060
|
+
* Fix default value for mysql time types with specified precision.
|
1267
1061
|
|
1268
|
-
*
|
1062
|
+
*Nikolay Kondratyev*
|
1269
1063
|
|
1270
|
-
*
|
1064
|
+
* Fix `touch` option to behave consistently with `Persistence#touch` method.
|
1271
1065
|
|
1272
|
-
*
|
1066
|
+
*Ryuta Kamizono*
|
1273
1067
|
|
1274
|
-
*
|
1068
|
+
* Migrations raise when duplicate column definition.
|
1275
1069
|
|
1276
|
-
|
1070
|
+
Fixes #33024.
|
1277
1071
|
|
1278
|
-
*
|
1072
|
+
*Federico Martinez*
|
1279
1073
|
|
1280
|
-
|
1074
|
+
* Bump minimum SQLite version to 3.8
|
1281
1075
|
|
1282
|
-
*
|
1283
|
-
are part of the URI structure, not the actual host.
|
1076
|
+
*Yasuo Honda*
|
1284
1077
|
|
1285
|
-
|
1078
|
+
* Fix parent record should not get saved with duplicate children records.
|
1286
1079
|
|
1287
|
-
|
1080
|
+
Fixes #32940.
|
1288
1081
|
|
1289
|
-
*
|
1290
|
-
through association are new.
|
1082
|
+
*Santosh Wadghule*
|
1291
1083
|
|
1292
|
-
|
1084
|
+
* Fix logic on disabling commit callbacks so they are not called unexpectedly when errors occur.
|
1293
1085
|
|
1294
|
-
*
|
1295
|
-
Serialized attributes on ActiveRecord models will no longer save when
|
1296
|
-
unchanged.
|
1086
|
+
*Brian Durand*
|
1297
1087
|
|
1298
|
-
|
1088
|
+
* Ensure `Associations::CollectionAssociation#size` and `Associations::CollectionAssociation#empty?`
|
1089
|
+
use loaded association ids if present.
|
1299
1090
|
|
1300
|
-
*
|
1091
|
+
*Graham Turner*
|
1301
1092
|
|
1302
|
-
*
|
1303
|
-
name.
|
1093
|
+
* Add support to preload associations of polymorphic associations when not all the records have the requested associations.
|
1304
1094
|
|
1305
|
-
|
1095
|
+
*Dana Sherson*
|
1306
1096
|
|
1307
|
-
|
1097
|
+
* Add `touch_all` method to `ActiveRecord::Relation`.
|
1308
1098
|
|
1309
|
-
|
1099
|
+
Example:
|
1310
1100
|
|
1311
|
-
|
1101
|
+
Person.where(name: "David").touch_all(time: Time.new(2020, 5, 16, 0, 0, 0))
|
1312
1102
|
|
1313
|
-
*
|
1103
|
+
*fatkodima*, *duggiefresh*
|
1314
1104
|
|
1315
|
-
|
1105
|
+
* Add `ActiveRecord::Base.base_class?` predicate.
|
1316
1106
|
|
1317
|
-
*
|
1318
|
-
`Enumerable#find` does.
|
1107
|
+
*Bogdan Gusiev*
|
1319
1108
|
|
1320
|
-
|
1109
|
+
* Add custom prefix/suffix options to `ActiveRecord::Store.store_accessor`.
|
1321
1110
|
|
1322
|
-
*
|
1111
|
+
*Tan Huynh*, *Yukio Mizuta*
|
1323
1112
|
|
1324
|
-
*
|
1113
|
+
* Rails 6 requires Ruby 2.5.0 or newer.
|
1325
1114
|
|
1326
|
-
|
1327
|
-
|
1328
|
-
*Kuldeep Aggarwal*, *Sean Griffin*
|
1329
|
-
|
1330
|
-
* `ActiveRecord::SchemaMigration` has no primary key regardless of the
|
1331
|
-
`primary_key_prefix_type` configuration.
|
1332
|
-
|
1333
|
-
Fixes #15051.
|
1334
|
-
|
1335
|
-
*JoseLuis Torres*, *Yves Senn*
|
1336
|
-
|
1337
|
-
* `rake db:migrate:status` works with legacy migration numbers like `00018_xyz.rb`.
|
1338
|
-
|
1339
|
-
Fixes #15538.
|
1340
|
-
|
1341
|
-
*Yves Senn*
|
1342
|
-
|
1343
|
-
* Baseclass becomes! subclass.
|
1344
|
-
|
1345
|
-
Before this change, a record which changed its STI type, could not be
|
1346
|
-
updated.
|
1347
|
-
|
1348
|
-
Fixes #14785.
|
1349
|
-
|
1350
|
-
*Matthew Draper*, *Earl St Sauver*, *Edo Balvers*
|
1351
|
-
|
1352
|
-
* Remove deprecated `ActiveRecord::Migrator.proper_table_name`. Use the
|
1353
|
-
`proper_table_name` instance method on `ActiveRecord::Migration` instead.
|
1354
|
-
|
1355
|
-
*Akshay Vishnoi*
|
1356
|
-
|
1357
|
-
* Fix regression on eager loading association based on SQL query rather than
|
1358
|
-
existing column.
|
1359
|
-
|
1360
|
-
Fixes #15480.
|
1361
|
-
|
1362
|
-
*Lauro Caetano*, *Carlos Antonio da Silva*
|
1363
|
-
|
1364
|
-
* Deprecate returning `nil` from `column_for_attribute` when no column exists.
|
1365
|
-
It will return a null object in Rails 5.0
|
1366
|
-
|
1367
|
-
*Sean Griffin*
|
1368
|
-
|
1369
|
-
* Implemented `ActiveRecord::Base#pretty_print` to work with PP.
|
1370
|
-
|
1371
|
-
*Ethan*
|
1372
|
-
|
1373
|
-
* Preserve type when dumping PostgreSQL point, bit, bit varying and money
|
1374
|
-
columns.
|
1375
|
-
|
1376
|
-
*Yves Senn*
|
1377
|
-
|
1378
|
-
* New records remain new after YAML serialization.
|
1379
|
-
|
1380
|
-
*Sean Griffin*
|
1381
|
-
|
1382
|
-
* PostgreSQL support default values for enum types. Fixes #7814.
|
1383
|
-
|
1384
|
-
*Yves Senn*
|
1385
|
-
|
1386
|
-
* PostgreSQL `default_sequence_name` respects schema. Fixes #7516.
|
1387
|
-
|
1388
|
-
*Yves Senn*
|
1389
|
-
|
1390
|
-
* Fix `columns_for_distinct` of PostgreSQL adapter to work correctly
|
1391
|
-
with orders without sort direction modifiers.
|
1392
|
-
|
1393
|
-
*Nikolay Kondratyev*
|
1394
|
-
|
1395
|
-
* PostgreSQL `reset_pk_sequence!` respects schemas. Fixes #14719.
|
1396
|
-
|
1397
|
-
*Yves Senn*
|
1398
|
-
|
1399
|
-
* Keep PostgreSQL `hstore` and `json` attributes as `Hash` in `@attributes`.
|
1400
|
-
Fixes duplication in combination with `store_accessor`.
|
1401
|
-
|
1402
|
-
Fixes #15369.
|
1403
|
-
|
1404
|
-
*Yves Senn*
|
1405
|
-
|
1406
|
-
* `rake railties:install:migrations` respects the order of railties.
|
1407
|
-
|
1408
|
-
*Arun Agrawal*
|
1409
|
-
|
1410
|
-
* Fix redefine a `has_and_belongs_to_many` inside inherited class
|
1411
|
-
Fixing regression case, where redefining the same `has_and_belongs_to_many`
|
1412
|
-
definition into a subclass would raise.
|
1413
|
-
|
1414
|
-
Fixes #14983.
|
1415
|
-
|
1416
|
-
*arthurnn*
|
1417
|
-
|
1418
|
-
* Fix `has_and_belongs_to_many` public reflection.
|
1419
|
-
When defining a `has_and_belongs_to_many`, internally we convert that to two has_many.
|
1420
|
-
But as `reflections` is a public API, people expect to see the right macro.
|
1421
|
-
|
1422
|
-
Fixes #14682.
|
1423
|
-
|
1424
|
-
*arthurnn*
|
1425
|
-
|
1426
|
-
* Fix serialization for records with an attribute named `format`.
|
1427
|
-
|
1428
|
-
Fixes #15188.
|
1429
|
-
|
1430
|
-
*Godfrey Chan*
|
1431
|
-
|
1432
|
-
* When a `group` is set, `sum`, `size`, `average`, `minimum` and `maximum`
|
1433
|
-
on a NullRelation should return a Hash.
|
1434
|
-
|
1435
|
-
*Kuldeep Aggarwal*
|
1436
|
-
|
1437
|
-
* Fix serialized fields returning serialized data after being updated with
|
1438
|
-
`update_column`.
|
1439
|
-
|
1440
|
-
*Simon Hørup Eskildsen*
|
1441
|
-
|
1442
|
-
* Fix polymorphic eager loading when using a String as foreign key.
|
1443
|
-
|
1444
|
-
Fixes #14734.
|
1445
|
-
|
1446
|
-
*Lauro Caetano*
|
1447
|
-
|
1448
|
-
* Change belongs_to touch to be consistent with timestamp updates
|
1449
|
-
|
1450
|
-
If a model is set up with a belongs_to: touch relationship the parent
|
1451
|
-
record will only be touched if the record was modified. This makes it
|
1452
|
-
consistent with timestamp updating on the record itself.
|
1453
|
-
|
1454
|
-
*Brock Trappitt*
|
1455
|
-
|
1456
|
-
* Fix the inferred table name of a `has_and_belongs_to_many` auxiliary
|
1457
|
-
table inside a schema.
|
1458
|
-
|
1459
|
-
Fixes #14824.
|
1460
|
-
|
1461
|
-
*Eric Chahin*
|
1462
|
-
|
1463
|
-
* Remove unused `:timestamp` type. Transparently alias it to `:datetime`
|
1464
|
-
in all cases. Fixes inconsistencies when column types are sent outside of
|
1465
|
-
`ActiveRecord`, such as for XML Serialization.
|
1466
|
-
|
1467
|
-
*Sean Griffin*
|
1468
|
-
|
1469
|
-
* Fix bug that added `table_name_prefix` and `table_name_suffix` to
|
1470
|
-
extension names in PostgreSQL when migrating.
|
1471
|
-
|
1472
|
-
*Joao Carlos*
|
1473
|
-
|
1474
|
-
* The `:index` option in migrations, which previously was only available for
|
1475
|
-
`references`, now works with any column types.
|
1476
|
-
|
1477
|
-
*Marc Schütz*
|
1478
|
-
|
1479
|
-
* Add support for counter name to be passed as parameter on `CounterCache::ClassMethods#reset_counters`.
|
1480
|
-
|
1481
|
-
*jnormore*
|
1482
|
-
|
1483
|
-
* Restrict deletion of record when using `delete_all` with `uniq`, `group`, `having`
|
1484
|
-
or `offset`.
|
1485
|
-
|
1486
|
-
In these cases the generated query ignored them and that caused unintended
|
1487
|
-
records to be deleted.
|
1488
|
-
|
1489
|
-
Fixes #11985.
|
1490
|
-
|
1491
|
-
*Leandro Facchinetti*
|
1492
|
-
|
1493
|
-
* Floats with limit >= 25 that get turned into doubles in MySQL no longer have
|
1494
|
-
their limit dropped from the schema.
|
1495
|
-
|
1496
|
-
Fixes #14135.
|
1497
|
-
|
1498
|
-
*Aaron Nelson*
|
1499
|
-
|
1500
|
-
* Fix how to calculate associated class name when using namespaced `has_and_belongs_to_many`
|
1501
|
-
association.
|
1502
|
-
|
1503
|
-
Fixes #14709.
|
1504
|
-
|
1505
|
-
*Kassio Borges*
|
1506
|
-
|
1507
|
-
* `ActiveRecord::Relation::Merger#filter_binds` now compares equivalent symbols and
|
1508
|
-
strings in column names as equal.
|
1509
|
-
|
1510
|
-
This fixes a rare case in which more bind values are passed than there are
|
1511
|
-
placeholders for them in the generated SQL statement, which can make PostgreSQL
|
1512
|
-
throw a `StatementInvalid` exception.
|
1513
|
-
|
1514
|
-
*Nat Budin*
|
1515
|
-
|
1516
|
-
* Fix `stored_attributes` to correctly merge the details of stored
|
1517
|
-
attributes defined in parent classes.
|
1518
|
-
|
1519
|
-
Fixes #14672.
|
1520
|
-
|
1521
|
-
*Brad Bennett*, *Jessica Yao*, *Lakshmi Parthasarathy*
|
1522
|
-
|
1523
|
-
* `change_column_default` allows `[]` as argument to `change_column_default`.
|
1524
|
-
|
1525
|
-
Fixes #11586.
|
1526
|
-
|
1527
|
-
*Yves Senn*
|
1528
|
-
|
1529
|
-
* Handle `name` and `"char"` column types in the PostgreSQL adapter.
|
1530
|
-
|
1531
|
-
`name` and `"char"` are special character types used internally by
|
1532
|
-
PostgreSQL and are used by internal system catalogs. These field types
|
1533
|
-
can sometimes show up in structure-sniffing queries that feature internal system
|
1534
|
-
structures or with certain PostgreSQL extensions.
|
1535
|
-
|
1536
|
-
*J Smith*, *Yves Senn*
|
1537
|
-
|
1538
|
-
* Fix `PostgreSQLAdapter::OID::Float#type_cast` to convert Infinity and
|
1539
|
-
NaN PostgreSQL values into a native Ruby `Float::INFINITY` and `Float::NAN`
|
1540
|
-
|
1541
|
-
Before:
|
1542
|
-
|
1543
|
-
Point.create(value: 1.0/0)
|
1544
|
-
Point.last.value # => 0.0
|
1545
|
-
|
1546
|
-
After:
|
1547
|
-
|
1548
|
-
Point.create(value: 1.0/0)
|
1549
|
-
Point.last.value # => Infinity
|
1550
|
-
|
1551
|
-
*Innokenty Mikhailov*
|
1552
|
-
|
1553
|
-
* Allow the PostgreSQL adapter to handle bigserial primary key types again.
|
1554
|
-
|
1555
|
-
Fixes #10410.
|
1556
|
-
|
1557
|
-
*Patrick Robertson*
|
1558
|
-
|
1559
|
-
* Deprecate joining, eager loading and preloading of instance dependent
|
1560
|
-
associations without replacement. These operations happen before instances
|
1561
|
-
are created. The current behavior is unexpected and can result in broken
|
1562
|
-
behavior.
|
1563
|
-
|
1564
|
-
Fixes #15024.
|
1565
|
-
|
1566
|
-
*Yves Senn*
|
1567
|
-
|
1568
|
-
* Fix `has_and_belongs_to_many` CollectionAssociation size calculations.
|
1569
|
-
|
1570
|
-
`has_and_belongs_to_many` should fall back to using the normal CollectionAssociation's
|
1571
|
-
size calculation if the collection is not cached or loaded.
|
1572
|
-
|
1573
|
-
Fixes #14913, #14914.
|
1574
|
-
|
1575
|
-
*Fred Wu*
|
1576
|
-
|
1577
|
-
* Return a non zero status when running `rake db:migrate:status` and migration table does
|
1578
|
-
not exist.
|
1579
|
-
|
1580
|
-
*Paul B.*
|
1581
|
-
|
1582
|
-
* Add support for module-level `table_name_suffix` in models.
|
1583
|
-
|
1584
|
-
This makes `table_name_suffix` work the same way as `table_name_prefix` when
|
1585
|
-
using namespaced models.
|
1586
|
-
|
1587
|
-
*Jenner LaFave*
|
1588
|
-
|
1589
|
-
* Revert the behaviour of `ActiveRecord::Relation#join` changed through 4.0 => 4.1 to 4.0.
|
1590
|
-
|
1591
|
-
In 4.1.0 `Relation#join` is delegated to `Arel#SelectManager`.
|
1592
|
-
In 4.0 series it is delegated to `Array#join`.
|
1593
|
-
|
1594
|
-
*Bogdan Gusiev*
|
1595
|
-
|
1596
|
-
* Log nil binary column values correctly.
|
1597
|
-
|
1598
|
-
When an object with a binary column is updated with a nil value
|
1599
|
-
in that column, the SQL logger would throw an exception when trying
|
1600
|
-
to log that nil value. This only occurs when updating a record
|
1601
|
-
that already has a non-nil value in that column since an initial nil
|
1602
|
-
value isn't included in the SQL anyway (at least, when dirty checking
|
1603
|
-
is enabled.) The column's new value will now be logged as `<NULL binary data>`
|
1604
|
-
to parallel the existing `<N bytes of binary data>` for non-nil values.
|
1605
|
-
|
1606
|
-
*James Coleman*
|
1607
|
-
|
1608
|
-
* Rails will now pass a custom validation context through to autosave associations
|
1609
|
-
in order to validate child associations with the same context.
|
1610
|
-
|
1611
|
-
Fixes #13854.
|
1612
|
-
|
1613
|
-
*Eric Chahin*, *Aaron Nelson*, *Kevin Casey*
|
1614
|
-
|
1615
|
-
* Stringify all variables keys of MySQL connection configuration.
|
1616
|
-
|
1617
|
-
When `sql_mode` variable for MySQL adapters set in configuration as `String`
|
1618
|
-
was ignored and overwritten by strict mode option.
|
1619
|
-
|
1620
|
-
Fixes #14895.
|
1621
|
-
|
1622
|
-
*Paul Nikitochkin*
|
1623
|
-
|
1624
|
-
* Ensure SQLite3 statements are closed on errors.
|
1625
|
-
|
1626
|
-
Fixes #13631.
|
1627
|
-
|
1628
|
-
*Timur Alperovich*
|
1629
|
-
|
1630
|
-
* Give `ActiveRecord::PredicateBuilder` private methods the privacy they deserve.
|
1631
|
-
|
1632
|
-
*Hector Satre*
|
1633
|
-
|
1634
|
-
* When using a custom `join_table` name on a `habtm`, rails was not saving it
|
1635
|
-
on Reflections. This causes a problem when rails loads fixtures, because it
|
1636
|
-
uses the reflections to set database with fixtures.
|
1637
|
-
|
1638
|
-
Fixes #14845.
|
1639
|
-
|
1640
|
-
*Kassio Borges*
|
1641
|
-
|
1642
|
-
* Reset the cache when modifying a Relation with cached Arel.
|
1643
|
-
Additionally display a warning message to make the user aware.
|
1644
|
-
|
1645
|
-
*Yves Senn*
|
1646
|
-
|
1647
|
-
* PostgreSQL should internally use `:datetime` consistently for TimeStamp. Assures
|
1648
|
-
different spellings of timestamps are treated the same.
|
1649
|
-
|
1650
|
-
Example:
|
1651
|
-
|
1652
|
-
mytimestamp.simplified_type('timestamp without time zone')
|
1653
|
-
# => :datetime
|
1654
|
-
mytimestamp.simplified_type('timestamp(6) without time zone')
|
1655
|
-
# => also :datetime (previously would be :timestamp)
|
1656
|
-
|
1657
|
-
See #14513.
|
1658
|
-
|
1659
|
-
*Jefferson Lai*
|
1660
|
-
|
1661
|
-
* `ActiveRecord::Base.no_touching` no longer triggers callbacks or start empty transactions.
|
1662
|
-
|
1663
|
-
Fixes #14841.
|
1664
|
-
|
1665
|
-
*Lucas Mazza*
|
1666
|
-
|
1667
|
-
* Fix name collision with `Array#select!` with `Relation#select!`.
|
1668
|
-
|
1669
|
-
Fixes #14752.
|
1670
|
-
|
1671
|
-
*Earl St Sauver*
|
1672
|
-
|
1673
|
-
* Fix unexpected behavior for `has_many :through` associations going through
|
1674
|
-
a scoped `has_many`.
|
1675
|
-
|
1676
|
-
If a `has_many` association is adjusted using a scope, and another
|
1677
|
-
`has_many :through` uses this association, then the scope adjustment is
|
1678
|
-
unexpectedly neglected.
|
1679
|
-
|
1680
|
-
Fixes #14537.
|
1681
|
-
|
1682
|
-
*Jan Habermann*
|
1683
|
-
|
1684
|
-
* `@destroyed` should always be set to `false` when an object is duped.
|
1685
|
-
|
1686
|
-
*Kuldeep Aggarwal*
|
1687
|
-
|
1688
|
-
* Enable `has_many` associations to support irregular inflections.
|
1689
|
-
|
1690
|
-
Fixes #8928.
|
1691
|
-
|
1692
|
-
*arthurnn*, *Javier Goizueta*
|
1693
|
-
|
1694
|
-
* Fix `count` used with a grouping not returning a Hash.
|
1695
|
-
|
1696
|
-
Fixes #14721.
|
1697
|
-
|
1698
|
-
*Eric Chahin*
|
1699
|
-
|
1700
|
-
* `sanitize_sql_like` helper method to escape a string for safe use in an SQL
|
1701
|
-
LIKE statement.
|
1702
|
-
|
1703
|
-
Example:
|
1704
|
-
|
1705
|
-
class Article
|
1706
|
-
def self.search(term)
|
1707
|
-
where("title LIKE ?", sanitize_sql_like(term))
|
1708
|
-
end
|
1709
|
-
end
|
1710
|
-
|
1711
|
-
Article.search("20% _reduction_")
|
1712
|
-
# => Query looks like "... title LIKE '20\% \_reduction\_' ..."
|
1713
|
-
|
1714
|
-
*Rob Gilson*, *Yves Senn*
|
1715
|
-
|
1716
|
-
* Do not quote uuid default value on `change_column`.
|
1717
|
-
|
1718
|
-
Fixes #14604.
|
1719
|
-
|
1720
|
-
*Eric Chahin*
|
1721
|
-
|
1722
|
-
* The comparison between `Relation` and `CollectionProxy` should be consistent.
|
1723
|
-
|
1724
|
-
Example:
|
1725
|
-
|
1726
|
-
author.posts == Post.where(author_id: author.id)
|
1727
|
-
# => true
|
1728
|
-
Post.where(author_id: author.id) == author.posts
|
1729
|
-
# => true
|
1730
|
-
|
1731
|
-
Fixes #13506.
|
1732
|
-
|
1733
|
-
*Lauro Caetano*
|
1734
|
-
|
1735
|
-
* Calling `delete_all` on an unloaded `CollectionProxy` no longer
|
1736
|
-
generates an SQL statement containing each id of the collection:
|
1737
|
-
|
1738
|
-
Before:
|
1739
|
-
|
1740
|
-
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
1741
|
-
AND `model`.`id` IN (1, 2, 3...)
|
1742
|
-
|
1743
|
-
After:
|
1744
|
-
|
1745
|
-
DELETE FROM `model` WHERE `model`.`parent_id` = 1
|
1746
|
-
|
1747
|
-
*Eileen M. Uchitelle*, *Aaron Patterson*
|
1748
|
-
|
1749
|
-
* Fix invalid SQL when aggregate methods (`empty?`, `any?`, `count`) used
|
1750
|
-
with `select`.
|
1751
|
-
|
1752
|
-
Fixes #13648.
|
1753
|
-
|
1754
|
-
*Simon Woker*
|
1755
|
-
|
1756
|
-
* PostgreSQL adapter only warns once for every missing OID per connection.
|
1757
|
-
|
1758
|
-
Fixes #14275.
|
1759
|
-
|
1760
|
-
*Matthew Draper*, *Yves Senn*
|
1761
|
-
|
1762
|
-
* PostgreSQL adapter automatically reloads it's type map when encountering
|
1763
|
-
unknown OIDs.
|
1764
|
-
|
1765
|
-
Fixes #14678.
|
1766
|
-
|
1767
|
-
*Matthew Draper*, *Yves Senn*
|
1768
|
-
|
1769
|
-
* Fix insertion of records via `has_many :through` association with scope.
|
1770
|
-
|
1771
|
-
Fixes #3548.
|
1772
|
-
|
1773
|
-
*Ivan Antropov*
|
1774
|
-
|
1775
|
-
* Auto-generate stable fixture UUIDs on PostgreSQL.
|
1776
|
-
|
1777
|
-
Fixes #11524.
|
1778
|
-
|
1779
|
-
*Roderick van Domburg*
|
1780
|
-
|
1781
|
-
* Fix a problem where an enum would overwrite values of another enum with the
|
1782
|
-
same name in an unrelated class.
|
1783
|
-
|
1784
|
-
Fixes #14607.
|
1785
|
-
|
1786
|
-
*Evan Whalen*
|
1787
|
-
|
1788
|
-
* PostgreSQL and SQLite string columns no longer have a default limit of 255.
|
1789
|
-
|
1790
|
-
Fixes #13435, #9153.
|
1791
|
-
|
1792
|
-
*Vladimir Sazhin*, *Toms Mikoss*, *Yves Senn*
|
1793
|
-
|
1794
|
-
* Make possible to have an association called `records`.
|
1795
|
-
|
1796
|
-
Fixes #11645.
|
1797
|
-
|
1798
|
-
*prathamesh-sonpatki*
|
1799
|
-
|
1800
|
-
* `to_sql` on an association now matches the query that is actually executed, where it
|
1801
|
-
could previously have incorrectly accrued additional conditions (e.g. as a result of
|
1802
|
-
a previous query). `CollectionProxy` now always defers to the association scope's
|
1803
|
-
`arel` method so the (incorrect) inherited one should be entirely concealed.
|
1804
|
-
|
1805
|
-
Fixes #14003.
|
1806
|
-
|
1807
|
-
*Jefferson Lai*
|
1808
|
-
|
1809
|
-
* Block a few default Class methods as scope name.
|
1810
|
-
|
1811
|
-
For instance, this will raise:
|
1812
|
-
|
1813
|
-
scope :public, -> { where(status: 1) }
|
1814
|
-
|
1815
|
-
*arthurnn*
|
1816
|
-
|
1817
|
-
* Fix error when using `with_options` with lambda.
|
1818
|
-
|
1819
|
-
Fixes #9805.
|
1820
|
-
|
1821
|
-
*Lauro Caetano*
|
1822
|
-
|
1823
|
-
* Switch `sqlite3:///` URLs (which were temporarily
|
1824
|
-
deprecated in 4.1) from relative to absolute.
|
1825
|
-
|
1826
|
-
If you still want the previous interpretation, you should replace
|
1827
|
-
`sqlite3:///my/path` with `sqlite3:my/path`.
|
1828
|
-
|
1829
|
-
*Matthew Draper*
|
1830
|
-
|
1831
|
-
* Treat blank UUID values as `nil`.
|
1832
|
-
|
1833
|
-
Example:
|
1834
|
-
|
1835
|
-
Sample.new(uuid_field: '') #=> <Sample id: nil, uuid_field: nil>
|
1836
|
-
|
1837
|
-
*Dmitry Lavrov*
|
1838
|
-
|
1839
|
-
* Enable support for materialized views on PostgreSQL >= 9.3.
|
1840
|
-
|
1841
|
-
*Dave Lee*
|
1842
|
-
|
1843
|
-
* The PostgreSQL adapter supports custom domains. Fixes #14305.
|
1844
|
-
|
1845
|
-
*Yves Senn*
|
1846
|
-
|
1847
|
-
* PostgreSQL `Column#type` is now determined through the corresponding OID.
|
1848
|
-
The column types stay the same except for enum columns. They no longer have
|
1849
|
-
`nil` as type but `enum`.
|
1850
|
-
|
1851
|
-
See #7814.
|
1852
|
-
|
1853
|
-
*Yves Senn*
|
1854
|
-
|
1855
|
-
* Fix error when specifying a non-empty default value on a PostgreSQL array
|
1856
|
-
column.
|
1857
|
-
|
1858
|
-
Fixes #10613.
|
1859
|
-
|
1860
|
-
*Luke Steensen*
|
1861
|
-
|
1862
|
-
* Fix error where `.persisted?` throws SystemStackError for an unsaved model with a
|
1863
|
-
custom primary key that did not save due to validation error.
|
1864
|
-
|
1865
|
-
Fixes #14393.
|
1866
|
-
|
1867
|
-
*Chris Finne*
|
1868
|
-
|
1869
|
-
* Introduce `validate` as an alias for `valid?`.
|
1870
|
-
|
1871
|
-
This is more intuitive when you want to run validations but don't care about the return value.
|
1872
|
-
|
1873
|
-
*Henrik Nyh*
|
1874
|
-
|
1875
|
-
* Create indexes inline in CREATE TABLE for MySQL.
|
1876
|
-
|
1877
|
-
This is important, because adding an index on a temporary table after it has been created
|
1878
|
-
would commit the transaction.
|
1879
|
-
|
1880
|
-
It also allows creating and dropping indexed tables with fewer queries and fewer permissions
|
1881
|
-
required.
|
1882
|
-
|
1883
|
-
Example:
|
1884
|
-
|
1885
|
-
create_table :temp, temporary: true, as: "SELECT id, name, zip FROM a_really_complicated_query" do |t|
|
1886
|
-
t.index :zip
|
1887
|
-
end
|
1888
|
-
# => CREATE TEMPORARY TABLE temp (INDEX (zip)) AS SELECT id, name, zip FROM a_really_complicated_query
|
1889
|
-
|
1890
|
-
*Cody Cutrer*, *Steve Rice*, *Rafael Mendonça Franca*
|
1891
|
-
|
1892
|
-
* Use singular table name in generated migrations when
|
1893
|
-
`ActiveRecord::Base.pluralize_table_names` is `false`.
|
1894
|
-
|
1895
|
-
Fixes #13426.
|
1896
|
-
|
1897
|
-
*Kuldeep Aggarwal*
|
1898
|
-
|
1899
|
-
* `touch` accepts many attributes to be touched at once.
|
1900
|
-
|
1901
|
-
Example:
|
1902
|
-
|
1903
|
-
# touches :signed_at, :sealed_at, and :updated_at/on attributes.
|
1904
|
-
Photo.last.touch(:signed_at, :sealed_at)
|
1905
|
-
|
1906
|
-
*James Pinto*
|
1907
|
-
|
1908
|
-
* `rake db:structure:dump` only dumps schema information if the schema
|
1909
|
-
migration table exists.
|
1910
|
-
|
1911
|
-
Fixes #14217.
|
1912
|
-
|
1913
|
-
*Yves Senn*
|
1914
|
-
|
1915
|
-
* Reap connections that were checked out by now-dead threads, instead
|
1916
|
-
of waiting until they disconnect by themselves. Before this change,
|
1917
|
-
a suitably constructed series of short-lived threads could starve
|
1918
|
-
the connection pool, without ever having more than a couple alive at
|
1919
|
-
the same time.
|
1920
|
-
|
1921
|
-
*Matthew Draper*
|
1922
|
-
|
1923
|
-
* `pk_and_sequence_for` now ensures that only the pg_depend entries
|
1924
|
-
pointing to pg_class, and thus only sequence objects, are considered.
|
1925
|
-
|
1926
|
-
*Josh Williams*
|
1927
|
-
|
1928
|
-
* `where.not` adds `references` for `includes` like normal `where` calls do.
|
1929
|
-
|
1930
|
-
Fixes #14406.
|
1931
|
-
|
1932
|
-
*Yves Senn*
|
1933
|
-
|
1934
|
-
* Extend fixture `$LABEL` replacement to allow string interpolation.
|
1935
|
-
|
1936
|
-
Example:
|
1937
|
-
|
1938
|
-
martin:
|
1939
|
-
email: $LABEL@email.com
|
1940
|
-
|
1941
|
-
users(:martin).email # => martin@email.com
|
1942
|
-
|
1943
|
-
*Eric Steele*
|
1944
|
-
|
1945
|
-
* Add support for `Relation` be passed as parameter on `QueryCache#select_all`.
|
1946
|
-
|
1947
|
-
Fixes #14361.
|
1948
|
-
|
1949
|
-
*arthurnn*
|
1950
|
-
|
1951
|
-
* Passing an Active Record object to `find` or `exists?` is now deprecated.
|
1952
|
-
Call `.id` on the object first.
|
1953
|
-
|
1954
|
-
*Aaron Patterson*
|
1955
|
-
|
1956
|
-
* Only use BINARY for MySQL case sensitive uniqueness check when column
|
1957
|
-
has a case insensitive collation.
|
1958
|
-
|
1959
|
-
*Ryuta Kamizono*
|
1960
|
-
|
1961
|
-
* Support for MySQL 5.6 fractional seconds.
|
1962
|
-
|
1963
|
-
*arthurnn*, *Tatsuhiko Miyagawa*
|
1964
|
-
|
1965
|
-
* Support for PostgreSQL `citext` data type enabling case-insensitive
|
1966
|
-
`where` values without needing to wrap in UPPER/LOWER sql functions.
|
1967
|
-
|
1968
|
-
*Troy Kruthoff*, *Lachlan Sylvester*
|
1969
|
-
|
1970
|
-
* Only save has_one associations if record has changes.
|
1971
|
-
Previously after save related callbacks, such as `#after_commit`, were triggered when the has_one
|
1972
|
-
object did not get saved to the db.
|
1973
|
-
|
1974
|
-
*Alan Kennedy*
|
1975
|
-
|
1976
|
-
* Allow strings to specify the `#order` value.
|
1977
|
-
|
1978
|
-
Example:
|
1979
|
-
|
1980
|
-
Model.order(id: 'asc').to_sql == Model.order(id: :asc).to_sql
|
1981
|
-
|
1982
|
-
*Marcelo Casiraghi*, *Robin Dupret*
|
1983
|
-
|
1984
|
-
* Dynamically register PostgreSQL enum OIDs. This prevents "unknown OID"
|
1985
|
-
warnings on enum columns.
|
1986
|
-
|
1987
|
-
*Dieter Komendera*
|
1988
|
-
|
1989
|
-
* `includes` is able to detect the right preloading strategy when string
|
1990
|
-
joins are involved.
|
1991
|
-
|
1992
|
-
Fixes #14109.
|
1993
|
-
|
1994
|
-
*Aaron Patterson*, *Yves Senn*
|
1995
|
-
|
1996
|
-
* Fix error with validation with enum fields for records where the value for
|
1997
|
-
any enum attribute is always evaluated as 0 during uniqueness validation.
|
1998
|
-
|
1999
|
-
Fixes #14172.
|
2000
|
-
|
2001
|
-
*Vilius Luneckas* *Ahmed AbouElhamayed*
|
2002
|
-
|
2003
|
-
* `before_add` callbacks are fired before the record is saved on
|
2004
|
-
`has_and_belongs_to_many` associations *and* on `has_many :through`
|
2005
|
-
associations. Before this change, `before_add` callbacks would be fired
|
2006
|
-
before the record was saved on `has_and_belongs_to_many` associations, but
|
2007
|
-
*not* on `has_many :through` associations.
|
2008
|
-
|
2009
|
-
Fixes #14144.
|
2010
|
-
|
2011
|
-
* Fix STI classes not defining an attribute method if there is a conflicting
|
2012
|
-
private method defined on its ancestors.
|
2013
|
-
|
2014
|
-
Fixes #11569.
|
2015
|
-
|
2016
|
-
*Godfrey Chan*
|
2017
|
-
|
2018
|
-
* Coerce strings when reading attributes. Fixes #10485.
|
2019
|
-
|
2020
|
-
Example:
|
1115
|
+
*Jeremy Daer*, *Kasper Timm Hansen*
|
2021
1116
|
|
2022
|
-
|
2023
|
-
book.save!
|
2024
|
-
book.title # => "12345"
|
1117
|
+
* Deprecate `update_attributes`/`!` in favor of `update`/`!`.
|
2025
1118
|
|
2026
|
-
*
|
1119
|
+
*Eddie Lebow*
|
2027
1120
|
|
2028
|
-
*
|
2029
|
-
|
2030
|
-
possible because the Ruby range does not support excluded beginnings.
|
1121
|
+
* Add `ActiveRecord::Base.create_or_find_by`/`!` to deal with the SELECT/INSERT race condition in
|
1122
|
+
`ActiveRecord::Base.find_or_create_by`/`!` by leaning on unique constraints in the database.
|
2031
1123
|
|
2032
|
-
|
2033
|
-
deprecated. For subtypes where we don't know how to increment (e.g. `#succ`
|
2034
|
-
is not defined) it will raise an `ArgumentException` for ranges with excluding
|
2035
|
-
beginnings.
|
1124
|
+
*DHH*
|
2036
1125
|
|
2037
|
-
|
1126
|
+
* Add `Relation#pick` as short-hand for single-value plucks.
|
2038
1127
|
|
2039
|
-
*
|
1128
|
+
*DHH*
|
2040
1129
|
|
2041
|
-
*Yves Senn*
|
2042
1130
|
|
2043
|
-
Please check [
|
1131
|
+
Please check [5-2-stable](https://github.com/rails/rails/blob/5-2-stable/activerecord/CHANGELOG.md) for previous changes.
|