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