aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
Commit message (Collapse)AuthorAgeFilesLines
* Copy edit the suppressor documentationRafael Mendonça França2015-02-191-13/+13
| | | | [ci skip]
* Add `ActiveRecord::Base.suppress`Michael Ryan2015-02-181-0/+29
|
* Add `time` option to `#touch`Hyonjee Joo2015-02-181-0/+5
| | | | | | Fixes #18905. `#touch` now takes time as an option. Setting the option saves the record with the updated_at/on attributes set to the current time or the time specified. Updated tests and documentation accordingly.
* Revert "Allow `:precision` option for time type columns"Sean Griffin2015-02-171-4/+0
| | | | | | | | | | This reverts commit 1502caefd30b137fd1a0865be34c5bbf85ba64c1. The test suite for the mysql adapter broke when this commit was used with MySQL 5.6. Conflicts: activerecord/CHANGELOG.md
* Deprecated passing of `start` value to `find_in_batches` and `find_each` in ↵Vipul A M2015-02-171-0/+5
| | | | favour of `begin_at` value.
* Merge pull request #18662 from estum/foreign-key-existsYves Senn2015-02-161-0/+4
|\ | | | | | | Add `foreign_key_exists?` method.
* | remove CHANGELOG entry for Rails 5.0 only feature. #18918Yves Senn2015-02-131-7/+0
| | | | | | | | | | `has_secure_token` hasen't been released yet. No need to track every change in the CHANGELOG.
* | Do not overwrite secret token value when already present.Wojciech Wnętrzak2015-02-121-0/+7
| | | | | | | | | | | | | | ``` user = User.create(token: "custom-secure-token") user.token # => "custom-secure-token" ```
* | Optimize none? and one? relation query methods to use LIMIT and COUNT.Eugene Gilburg2015-02-121-0/+22
| | | | | | | | | | | | | | | | Use SQL COUNT and LIMIT 1 queries for none? and one? methods if no block or limit is given, instead of loading the entire collection to memory. The any? and many? methods already follow this behavior. [Eugene Gilburg & Rafael Mendonça França]
* | Allow `:precision` option for time type columnsRyuta Kamizono2015-02-121-0/+4
| |
* | Refactor enum to be defined in terms of the attributes APISean Griffin2015-02-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | In addition to cleaning up the implementation, this allows type casting behavior to be applied consistently everywhere. (#where for example). A good example of this was the previous need for handling value to key conversion in the setter, because the number had to be passed to `where` directly. This is no longer required, since we can just pass the string along to where. (It's left around for backwards compat) Fixes #18387
* | `current_scope` shouldn't pollute sibling STI classesSean Griffin2015-02-111-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | It looks like the only reason `current_scope` was thread local on `base_class` instead of `self` is to ensure that when we call a named scope created with a proc on the parent class, it correctly uses the default scope of the subclass. The reason this wasn't happening was because the proc captured `self` as the parent class, and we're not actually defining a real method. Using `instance_exec` fixes the problem. Fixes #18806
* | fix `remove_reference` with `foreign_key: true` on MySQL. #18664.Yves Senn2015-02-111-0/+8
| | | | | | | | | | | | | | | | | | | | MySQL rejects to remove an index which is used in a foreign key constraint: ``` ActiveRecord::StatementInvalid: Mysql2::Error: Cannot drop index 'index_copies_on_title_id': needed in a foreign key constraint: ALTER TABLE `copies` DROP `title_id` ``` Removing the constraint before removing the column (and the index) solves this problem.
* | Merge pull request #18877 from prathamesh-sonpatki/ar-changelog-typos-2Rafael Mendonça França2015-02-101-2/+2
|\ \ | | | | | | Fixed typos in ActiveRecord CHANGELOG [ci skip]
| * | Fixed typos in ActiveRecord CHANGELOG [ci skip]Prathamesh Sonpatki2015-02-111-2/+2
| | |
* | | Add an option `end_at` to `find_in_batches`Vipul A M2015-02-091-0/+5
|/ / | | | | | | that complements the `start`parameter to specify where to stop batch processing
* | Fix rounding problem for PostgreSQL timestamp columnRyuta Kamizono2015-02-081-0/+7
| | | | | | | | | | If timestamp column have the precision, it need to format according to the precision of timestamp column.
* | Respect the database default charset for `schema_migrations` table.Ryuta Kamizono2015-02-081-0/+8
| | | | | | | | | | | | The charset of `version` column in `schema_migrations` table is depend on the database default charset and collation rather than the encoding of the connection.
* | Raise ArgumentError when passing nil to Relation#mergeRafael Mendonça França2015-02-061-0/+7
| | | | | | | | | | | | nil or false should not be valid argument to the merge method. Closes #12264
* | Merge pull request #18399 from kommen/unify-structure-file-envvar-namesRafael Mendonça França2015-02-051-0/+6
|\ \ | | | | | | | | | | | | | | | | | | Use SCHEMA instead of DB_STRUCTURE for specifiying structure file. Conflicts: activerecord/CHANGELOG.md
| * | Use `SCHEMA` instead of `DB_STRUCTURE` for specifiying structure file.Dieter Komendera2015-01-081-0/+6
| | | | | | | | | | | | | | | `rake test:load_structure` already uses `SCHEMA` and there's no need to maintain two different env vars.
* | | Respect custom primary keys for associations in `Relation#where`Sean Griffin2015-02-041-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While we query the proper columns, we go through normal handling for converting the value to a primitive which assumes it should use the table's primary key. If the association specifies a different value (and we know that we're working with an association), we should use the custom primary key instead. Fixes #18813.
* | | Correct errors in counter cache updatingSean Griffin2015-02-031-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The cache name should be converted to a string when given, not compared as a symbol. This edge case is already adequately covered by our tests, but was masked by another issue where we were incorrectly updating the counter cache twice. When paired with a bug where we didn't update the counter cache because we couldn't find a match with the name, this made it look like everything was working fine. Fixes #10865.
* | | Generate consistent names for foreign keysChris Sinjakli2015-02-031-0/+9
| | |
* | | Fix validations on child record when record parent has validate: falseeileencodes2015-02-011-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #17621. This 5 year old (or older) issue causes validations to fire when a parent record has `validate: false` option and a child record is saved. It's not the responsibility of the model to validate an associated object unless the object was created or modified by the parent. Clean up tests related to validations `assert_nothing_raised` is not benefiting us in these tests Corrected spelling of "respects" It's better to use `assert_not_operator` over `assert !r.valid`
* | | Merge branch 'master' into mdluo-masterAaron Patterson2015-02-011-0/+5
|\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: Move required error message and changelog to Active Record Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846 Use Module#include instead of send :include, since now is a public method [ci skip] :scissors: warning from controller renderer test Conflicts: activerecord/CHANGELOG.md
| * | | Move required error message and changelog to Active RecordCarlos Antonio da Silva2015-02-011-0/+5
| | | | | | | | | | | | | | | | | | | | The new association error belongs to Active Record, not Active Model. See #18700 for reference.
* | | | Merge branch 'master' into pr/18316Mingdong Luo2015-01-311-1/+218
|\| | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG.md
| * | | unify CHANGELOG format. [ci skip]Yves Senn2015-01-311-3/+5
| | | |
| * | | Fixed AR::Relation#group method when argument is a SQL reserved keywordBogdan Gusiev2015-01-291-0/+7
| | | |
| * | | Added #or to ActiveRecord::RelationMatthew Draper2015-01-281-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Post.where('id = 1').or(Post.where('id = 2')) # => SELECT * FROM posts WHERE (id = 1) OR (id = 2) [Matthew Draper & Gael Muller]
| * | | Don't redefine autosave association callbacks in nested attrsSean Griffin2015-01-281-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These callbacks will already have been defined when the association was built. The check against `reflection.autosave` happens at call time, not at define time, so simply modifying the reflection is sufficient. Fixes #18704
| * | | Move integer range validation to never raise on assignmentSean Griffin2015-01-231-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given that this was originally added to normalize an error that would have otherwise come from the database (inconsistently), it's more natural for us to raise in `type_cast_for_database`, rather than `type_cast_from_user`. This way, things like numericality validators can handle it instead if the user chooses to do so. It also fixes an issue where assigning an out of range value would make it impossible to assign a new value later. This fixes several vague issues, none of which were ever directly reported, so I have no issue number to give. Places it was mentioned which I can remember: - https://github.com/thoughtbot/shoulda-matchers/blob/9ba21381d7caf045053a81f32df7de2f49687820/lib/shoulda/matchers/active_model/allow_value_matcher.rb#L261-L263 - https://github.com/rails/rails/issues/18653#issuecomment-71197026
| * | | Errors raised in `type_cast_for_database` no longer raise on assignmentSean Griffin2015-01-231-1/+10
| | | | | | | | | | | | | | | | Fixes #18580.
| * | | Don't remove join dependencies in `Relation#exists?`Sean Griffin2015-01-231-0/+6
| | |/ | |/| | | | | | | Fixes #18632
| * | Don't error when invalid json is assigned to a JSON columnSean Griffin2015-01-211-0/+6
| | | | | | | | | | | | | | | | | | | | | Keeping with our behavior elsewhere in the system, invalid input is assumed to be `nil`. Fixes #18629.
| * | Introduce `ActiveRecord::Base#accessed_fields`Sean Griffin2015-01-201-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This method can be used to see all of the fields on a model which have been read. This can be useful during development mode to quickly find out which fields need to be selected. For performance critical pages, if you are not using all of the fields of a database, an easy performance win is only selecting the fields which you need. By calling this method at the end of a controller action, it's easy to determine which fields need to be selected. While writing this, I also noticed a place for an easy performance win internally which I had been wanting to introduce. You cannot mutate a field which you have not read. Therefore, we can skip the calculation of in place changes if we have never read from the field. This can significantly speed up methods like `#changed?` if any of the fields have an expensive mutable type (like `serialize`) ``` Calculating ------------------------------------- #changed? with serialized column (before) 391.000 i/100ms #changed? with serialized column (after) 1.514k i/100ms ------------------------------------------------- #changed? with serialized column (before) 4.243k (± 3.7%) i/s - 21.505k #changed? with serialized column (after) 16.789k (± 3.2%) i/s - 84.784k ```
| * | Merge pull request #18458 from brainopia/fix_after_commit_for_fixturesJeremy Kemper2015-01-201-0/+9
| |\ \ | | | | | | | | Support after_commit callbacks in transactional fixtures
| | * | after_commit runs after transactions with non-joinable parentsbrainopia2015-01-161-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | after_commit callbacks run after committing a transaction whose parent is not `joinable?`: un-nested transactions, transactions within test cases, and transactions in `console --sandbox`.
| * | | Merge pull request #18597 from kamipo/add-if-exists-to-drop-tableYves Senn2015-01-201-0/+15
| |\ \ \ | | | | | | | | | | Add an `:if_exists` option to `drop_table`
| | * | | Add an `:if_exists` option to `drop_table`Stefan Kanev2015-01-191-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If set to `if_exists: true`, it generates a statement like: DROP TABLE IF EXISTS posts This syntax is supported in the popular SQL servers, that is (at least) SQLite, PostgreSQL, MySQL, Oracle and MS SQL Sever. Closes #16366.
| * | | | Fix wording in AR CHANGELOG about time columns change [ci skip]Prathamesh Sonpatki2015-01-191-1/+1
| |/ / /
| * | | Run SQL only if attribute changed for update_attribute methodPrathamesh Sonpatki2015-01-181-0/+4
| | | | | | | | | | | | | | | | | | | | - This is based on https://github.com/rails/rails/issues/18400 but tackling same issue with update_attribute method instead of update method.
| * | | Specify correct version in the changelog [ci skip]Sean Griffin2015-01-161-1/+1
| |/ /
| * | Time columns should support time zone aware attributesSean Griffin2015-01-151-0/+14
| | | | | | | | | | | | | | | | | | The types that are affected by `time_zone_aware_attributes` (which is on by default) have been made configurable, in case this is a breaking change for existing applications.
| * | Stop special casing null binary data in loggingSean Griffin2015-01-101-0/+5
| | | | | | | | | | | | | | | | | | There's very little value in logging "<NULL binary data>" instead of just "nil". I'd like to remove the column from the equation entirely, and this case is preventing us from doing so.
| * | Don't attempt to save dirty attributes which are not persistableSean Griffin2015-01-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This sets a precident for how we handle `attribute` calls, which aren't backed by a database column. We should not take this as a conscious decision on how to handle them, and this can change when we make `attribute` public if we have better ideas in the future. As the composed attributes API gets fleshed out, I expect the `persistable_attributes` method to change to `@attributes.select(&:persistable).keys`, or some more performant variant there-of. This can probably go away completely once we fully move dirty checking into the attribute objects once it gets moved up to Active Model. Fixes #18407
| * | formatting pass over CHANGELOGs. [ci skip]Yves Senn2015-01-101-2/+2
| | |
| * | Remove support for the protected attributes gemCarlos Antonio da Silva2015-01-091-0/+4
| |/ | | | | | | Related to #10690.
| * Fixed typos and wording in ActiveRecord CHANGELOG [ci skip]Prathamesh Sonpatki2015-01-061-5/+5
| |