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