aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
Commit message (Collapse)AuthorAgeFilesLines
* Configuration item `config.filter_parameters` could also filter out ↵Zhang Kang2018-09-071-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | sensitive value of database column when call `#inspect` * Why Some sensitive data will be exposed in log accidentally by calling `#inspect`, e.g. ```ruby @account = Account.find params[:id] payload = { account: @account } logger.info "payload will be #{ payload }" ``` All the information of `@account` will be exposed in log. * Solution Add a class attribute filter_attributes to specify which values of columns shouldn't be exposed. This attribute equals to `Rails.application.config.filter_parameters` by default. ```ruby Rails.application.config.filter_parameters += [:credit_card_number] Account.last.insepct # => #<Account id: 123, credit_card_number: [FILTERED] ...> ```
* Formatting CHANGELOGs [ci skip]Ryuta Kamizono2018-09-071-4/+4
| | | | Fixing code block rendering, indentation, backticks, etc.
* Deprecate most methods which were never used in `DatabaseLimits`Ryuta Kamizono2018-09-051-0/+6
| | | | | | | | | `DatabaseLimits` and those methods were introduced at 3809c80, but most methods were never used and never tested from the beginning (except `table_alias_length`, `index_name_length`, and `in_clause_length` (since 66c09372)). There is no reason to maintain unused those methods for about 8 years.
* Refactors Active Record connection managementEileen Uchitelle2018-08-301-0/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the three-tier config makes it easier to define databases for multiple database applications, it quickly became clear to offer full support for multiple databases we need to change the way the connections hash was handled. A three-tier config means that when Rails needed to choose a default configuration (in the case a user doesn't ask for a specific configuration) it wasn't clear to Rails which the default was. I [bandaid fixed this so the rake tasks could work](#32271) but that fix wasn't correct because it actually doubled up the configuration hashes. Instead of attemping to manipulate the hashes @tenderlove and I decided that it made more sense if we converted the hashes to objects so we can easily ask those object questions. In a three tier config like this: ``` development: primary: database: "my_primary_db" animals: database; "my_animals_db" ``` We end up with an object like this: ``` @configurations=[ #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>, #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90 @env_name="development",@spec_name="animals", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}> ]> ``` The configurations setter takes the database configuration set by your application and turns them into an `ActiveRecord::DatabaseConfigurations` object that has one getter - `@configurations` which is an array of all the database objects. The configurations getter returns this object by default since it acts like a hash in most of the cases we need. For example if you need to access the default `development` database we can simply request it as we did before: ``` ActiveRecord::Base.configurations["development"] ``` This will return primary development database configuration hash: ``` { "database" => "my_primary_db" } ``` Internally all of Active Record has been converted to use the new objects. I've built this to be backwards compatible but allow for accessing the hash if needed for a deprecation period. To get the original hash instead of the object you can either add `to_h` on the configurations call or pass `legacy: true` to `configurations. ``` ActiveRecord::Base.configurations.to_h => { "development => { "database" => "my_primary_db" } } ActiveRecord::Base.configurations(legacy: true) => { "development => { "database" => "my_primary_db" } } ``` The new configurations object allows us to iterate over the Active Record configurations without losing the known environment or specification name for that configuration. You can also select all the configs for an env or env and spec. With this we can always ask any object what environment it belongs to: ``` db_configs = ActiveRecord::Base.configurations.configurations_for("development") => #<ActiveRecord::DatabaseConfigurations:0x00007fd1acbdf800 @configurations=[ #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbded10 @env_name="development",@spec_name="primary", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}>, #<ActiveRecord::DatabaseConfigurations::HashConfig:0x00007fd1acbdea90 @env_name="development",@spec_name="animals", @config={"adapter"=>"sqlite3", "database"=>"db/development.sqlite3"}> ]> db_config.env_name => "development" db_config.spec_name => "primary" db_config.config => { "adapter"=>"sqlite3", "database"=>"db/development.sqlite3" } ``` The configurations object is more flexible than the configurations hash and will allow us to build on top of the connection management in order to add support for primary/replica connections, sharding, and constructing queries for associations that live in multiple databases.
* Add database configuration to disable advisory locks.Guo Xiang Tan2018-08-221-0/+10
| | | | https://github.com/rails/rails/issues/31190
* Merge pull request #33585 from yahonda/diag33520Ryuta Kamizono2018-08-161-0/+4
|\ | | | | | | SQLite3 adapter `alter_table` method restores foreign keys
| * SQLite3 adapter `alter_table` method restores foreign keysYasuo Honda2018-08-111-0/+4
| | | | | | | | Related to #33520
* | Follow up #33530bogdanvlviv2018-08-151-4/+8
| | | | | | | | | | | | | | | | | | - Move changelog entry of #33530 up in order to preserve the chronology since we always add new entries on the top of a changelog file. - Clarify the changelog entry - Clarify the docs of remove_foreign_key - Ensure reversible of `remove_foreign_key` with `:primary_key` and `:to_table` options.
* | Allow `to_table` in `invert_remove_foreign_key`Rich2018-08-141-0/+4
|/ | | | | | | | | | | | remove_foreign_key supports - remove_foreign_key :accounts, :branches - remove_foreign_key :accounts, to_table: :branches but the second one is not reversible. This branch is to fix and allow second one to be reversible. [Nikolay Epifanov, Rich Chen]
* Revert "Merge pull request #24131 from brchristian/limit_and_primary_key"Ryuta Kamizono2018-08-011-6/+0
| | | | | | | | | | This reverts commit d162188dd662a7d9f62ba8431474f50bc35e3e93, reversing changes made to 3576782888c307e3e192c44e332b957cd1174128. Reason: #24131 conflicts the #5153's default order contract, it means that existing apps would be broken by that change. We don't want to break existing apps without a deprecation cycle.
* CHANGELOG entryBrian Christian2018-07-191-0/+6
|
* Add missing load config dependency to `rake db:seed`Tobias Bielohlawek2018-07-101-0/+5
|
* Merge pull request #33280 from nkondratyev/fix/mysql-time-default-valuesRyuta Kamizono2018-07-091-0/+4
|\ | | | | | | Fix default value for mysql time types with specified precision
| * Fix default value for mysql time types with specified precisionNikolay Kondratyev2018-07-041-0/+4
|/ | | | | | | | | | | | | | | | The TIME, DATETIME, and TIMESTAMP types [have supported](https://mariadb.com/kb/en/library/microseconds-in-mariadb/) a fractional seconds precision from 0 to 6. Default values from time columns with specified precision is read as `current_timestamp(n)` from information schema. rake `db:schema:dump` produces `schema.rb` **without** default values for time columns with the specified precision: t.datetime "last_message_at", precision: 6, null: false rake `db:schema:dump` produces `schema.rb` **with** default values for time columns with the specified precision: t.datetime "last_message_at", precision: 6, default: -> { "current_timestamp(6)" }, null: false
* Fix `touch` option to behave consistently with `Persistence#touch` methodRyuta Kamizono2018-06-181-0/+4
| | | | | | | | | | | | | | | | `touch` option was added to `increment!` (#27660) and `update_counters` (#26995). But that option behaves inconsistently with `Persistence#touch` method. If `touch` option is passed attribute names, it won't update update_at/on attributes unlike `Persistence#touch` method. Due to changed from `Persistence#touch` to `increment!` with `touch` option, #31405 has a regression that `counter_cache` with `touch` option which is passed attribute names won't update update_at/on attributes. I think that the inconsistency is not intended. To get back consistency, ensure that `touch` option updates update_at/on attributes.
* Merge pull request #29373 from untidy-hair/store_accessor_enhanceRyuta Kamizono2018-06-131-2/+2
|\ | | | | | | Allow prefix/suffix options for store accessors
* | :scissors:Ryuta Kamizono2018-06-101-1/+1
| | | | | | | | [ci skip]
* | Migrations will raise an exception if there are multiple column definitions ↵Federico Martinez2018-06-011-0/+6
| | | | | | | | (same name).
* | [skip ci] Add changelog about bumping minimum SQLite version to 3.8Yasuo Honda2018-06-011-0/+4
| | | | | | | | Related to #32923
* | Merge pull request #32952 from mechanicles/32940-fixRyuta Kamizono2018-05-291-0/+6
|\ \ | |/ |/| | | Fix parent record should not get saved with duplicate children records
| * Fix parent record should not get saved with duplicate children recordsSantosh Wadghule2018-05-281-0/+6
|/ | | | - Fixes #32940
* Fix logic on disabling commit callbacksBrian Durand2018-05-041-0/+4
| | | | Commit callbacks are intentionally disabled when errors occur when calling the callback chain in order to reset the internal record state. However, the implicit order of operations on the logic for checking if callbacks are disabled is wrong. The result is that callbacks can be unexpectedly when errors occur in transactions.
* Loaded associations should not run a new query when size is calledGraham Turner2018-04-261-0/+5
| | | | | | | Already loaded associations were running an extra query when `size` was called on the association. This fix ensures that an extra query is no longer run. Update tests to use proper methods
* Can preload associations through polymorphic associationsDana Sherson2018-04-201-0/+4
|
* Add `touch_all` method to `ActiveRecord::Relation`fatkodima2018-04-131-0/+8
|
* [ci skip] Fully quantify Active Record module in changelog.Kasper Timm Hansen2018-04-021-1/+1
|
* Add AR::Base.base_class? predicateBogdan Gusiev2018-04-021-0/+4
|
* Add custom prefix to ActiveRecord::Store accessorsTan Huynh2018-03-231-0/+4
| | | | | | Add a prefix option to ActiveRecord::Store.store_accessor and ActiveRecord::Store.store. This option allows stores to have identical keys with different accessors.
* Remove changelog header for unreleased versionRafael Mendonça França2018-03-131-2/+0
| | | | | | We only add the header when releasing to avoid some conflicts. [ci skip]
* Remove CHANGELOG entries which were backported to 5-2-stableRyuta Kamizono2018-02-281-14/+0
|
* Fix a typo in activerecord/CHANGELOG.mdokkez2018-02-281-1/+1
| | | | columsn -> columns
* Merge pull request #31966 from kg8m/fix_limited_ids_forRyuta Kamizono2018-02-281-0/+8
|\ | | | | | | Use column alias of primary_key in limited_ids_for
| * Fix `#columsn_for_distinct` of MySQL and PostgreSQLkg8m2018-02-271-0/+8
|/ | | | | | | Prevent `ActiveRecord::FinderMethods#limited_ids_for` from using correct primary key values even if `ORDER BY` columns include other table's primary key. Fixes #28364.
* Make `reflection.klass` raise if `polymorphic?` not to be misusedRyuta Kamizono2018-02-191-0/+6
| | | | | | | | | | | | | | | | This is an alternative of #31877 to fix #31876 caused by #28808. This issue was caused by a combination of several loose implementation. * finding automatic inverse association of polymorphic without context (caused by #28808) * returning `klass` even if `polymorphic?` (exists before #28808) * loose verification by `valid_inverse_reflection?` (exists before #28808) This makes `klass` raise if `polymorphic?` not to be misused. This issue will not happen unless polymorphic `klass` is misused. Fixes #31876. Closes #31877.
* Add a CHANGELOG entry for #31941 [ci skip]Ryuta Kamizono2018-02-191-0/+4
|
* Rails 6 requires Ruby 2.4.1+Jeremy Daer2018-02-171-0/+5
| | | | | | Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug. References #32028
* Deprecate update_attributes and update_attributes!Eddie Lebow2018-02-171-0/+3
| | | | Closes #31998
* Add #create_or_find_by to lean on unique constraints (#31989)David Heinemeier Hansson2018-02-141-0/+6
| | | Add #create_or_find_by to lean on unique constraints
* Start Rails 6.0 development!!!Rafael Mendonça França2018-01-301-667/+1
| | | | :tada::tada::tada:
* Deprecate `expand_hash_conditions_for_aggregates`Ryuta Kamizono2018-01-291-0/+5
| | | | | This can not expand an array of aggregated objects correctly, and is no longer used internally since 159b21b5.
* Merge pull request #31724 from orekyuu/fix-expand-composed-object-arrayRyuta Kamizono2018-01-291-0/+14
|\ | | | | | | Fix not expanded problem when passing an Array object as argument to the where method using composed_of column.
| * Fix not expanded problem when passing an Array object as argument to the ↵orekyuu2018-01-261-0/+14
|/ | | | | | | | | | | | | | where method using composed_of column. Fixes #31723 ``` david_balance = customers(:david).balance Customer.where(balance: [david_balance]).to_sql # Before: WHERE `customers`.`balance` = NULL # After : WHERE `customers`.`balance` = 50 ```
* Fix `count(:all)` with eager loading and having an order other than the ↵Ryuta Kamizono2018-01-251-0/+6
| | | | | | | | | | | | | | | | | | | driving table This is a regression caused by 6beb4de. In PostgreSQL, ORDER BY expressions must appear in SELECT list when using DISTINCT. When using `count(:all)` with eager loading, Active Record enforces DISTINCT to count the driving table records only. 6beb4de was caused the regression because `count(:all)` with DISTINCT path no longer removes ORDER BY. We need to ignore ORDER BY when DISTINCT is enforced, otherwise not always generated valid SQL for PostgreSQL. Fixes #31783.
* Expand AR to Active Record [ci skip]Ryuta Kamizono2018-01-251-2/+2
|
* Clear the transaction state when AR object is dupedYuriy Ustushenko2018-01-251-0/+6
|
* Support for PostgreSQL foreign tablesfatkodima2018-01-221-0/+4
|
* Fix relation merger issue with `left_outer_joins`Mehmet Emin INAC2018-01-151-0/+4
|
* Don't allow destroyed object mutation after `save` or `save!` is calledRyuta Kamizono2018-01-151-0/+4
| | | | | | | | | | Currently `object.save` will unfreeze the object, due to `changes_applied` replaces frozen `@attributes` to new `@attributes`. Since originally destroyed objects are not allowed to be mutated, `save` and `save!` should not return success in that case. Fixes #28563.
* Merge pull request #23146 from piotrj/issue_18424Ryuta Kamizono2018-01-111-0/+6
|\ | | | | | | When deleting through records, take into account association conditions
* \ Merge pull request #16314 from ↵Ryuta Kamizono2018-01-101-0/+38
|\ \ | | | | | | | | | | | | | | | zoltankiss/allow-nested-has-many-associations-on-unpersisted-parent-instances fix nested `has many :through` associations on unpersisted parent instances