aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
Commit message (Collapse)AuthorAgeFilesLines
* changelog entry for fc4c15d [ci skip]Yves Senn2016-11-211-0/+5
| | | | https://github.com/rails/rails/commit/fc4c15d823b112cc440cbd9a4288e1a389c138da
* Merge pull request #26981 from kamipo/should_not_except_order_for_existsRafael França2016-11-171-1/+2
|\ | | | | Should except `:distinct` rather than `:order` for `exists?`
| * Should except `:distinct` rather than `:order` for `exists?`Ryuta Kamizono2016-11-091-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Records fetching order is very important for performance if `limit` is presented. Should not except the order in the case. And `exists?` replaces select list to `1 AS one` therefore `:distinct` is useless (`DISTINCT 1 AS one`). And PostgreSQL raises the following error if `:distinct` and `:order` are used in the same time. ``` ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list ```
* | Support AC::Parameters for PG HStoreJon Moss2016-11-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As reported via #26904, there is a regression in how values for Postgres' HStore column type are being processed, beginning in Rails 5. Currently, the way that Active Record checks whether or not values need to be serialized and put into the correct storage format is whether or not it is a `Hash` object. Since `ActionController::Parameters` no longer inherits from `Hash` in Rails 5, this conditional now returns false. To remedy this, we are now checking to see whether the `value` parameters being passed in responds to a certain method, and then calling the `serialize` method, except this time with a real Hash object. Keeping things DRY! Fixes #26904.
* | Changelog editsVipul A M2016-11-121-7/+7
|/
* Add ActiveRecord::Base.connection_pool.statPavel2016-11-091-0/+9
|
* Avoid `unscope(:order)` when `limit_value` is presented for `count`Ryuta Kamizono2016-11-061-2/+11
| | | | | If `limit_value` is presented, records fetching order is very important for performance. Should not unscope the order in the case.
* fix datatime errorSen-Zhang2016-11-011-0/+5
|
* allow ActiveRecord::Core#slice to use array argCohen Carlisle2016-10-311-0/+4
|
* Merge PR #19759Arthur Neves2016-10-281-0/+7
|\ | | | | | | Fix for has_and_belongs_to_many & has_many_through associations
| * Fix for has_and_belongs_to_many & has_many_through associations while ↵Mehmet Emin İNAÇ2016-02-131-1/+7
| | | | | | | | | | | | | | | | partial_writes is false This will fix #19663 Also with this fix, active record does not fire unnecassary update queries while partial_writes is true
* | Revert "Made ActiveRecord consistently use ActiveRecord::Type (not"Sean Griffin2016-10-231-4/+0
| | | | | | | | | | | | This reverts commit 671eb742eec77b5c8281ac2a2e3976ef32a6e424. This is not a change we would like moving forward.
* | Fix regression caused due to removal of select method from CollectionAssociationPrathamesh Sonpatki2016-10-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - CollectionAssociation#select was removed in https://github.com/rails/rails/pull/25989 in favor of QueryMethods#select but it caused a regression when passing arguments to select and a block. - This used to work earlier in Rails 4.2 and Rails 5. See gist https://gist.github.com/prathamesh-sonpatki/a7df922273473a77dfbc742a4be4b618. - This commit restores the behavior of Rails 4.2 and Rails 5.0.0 to allow passing arguments and block at the same time but also deprecates it. - Because, these arguments do not have any effect on the output of select when select is used with a block. - Updated documentation to remove the example passing arguments and block at the same time to `CollectionProxy#select`.
* | Added ability update locking_column valuebogdanvlviv2016-10-211-0/+5
| |
* | Fixed: Optimistic locking does not work well with null in the databasebogdanvlviv2016-10-211-0/+6
| |
* | Merge pull request #26208 from nanaya/pg-insensitive-textMatthew Draper2016-10-111-0/+5
|\ \ | | | | | | | | | Fix case insensitive check for text column in pg
* | | Made ActiveRecord consistently use ActiveRecord::Type (notIain Beeston2016-10-031-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | ActiveModel::Type) Some code was previously referring to ActiveModel::Type::*. This could cause issues in the future if any of the ActiveRecord::Type classes were overridden in the future.
* | | Serialize JSON attribute value nil as SQL NULL, not JSON 'null'Trung Duc Tran2016-09-231-0/+4
| | | | | | | | | | | | | | | | | | Test: JSON attribute value nil can be used in where(attr: nil) Add changelog entry
* | | Return true if attribute is not changed for update_attributePrathamesh Sonpatki2016-09-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - If the attribute is not changed, then update_attribute does not run SQL query, this effectively means that no change was made to the attribute. - This change was made in https://github.com/rails/rails/commit/0fcd4cf5 to avoid a SQL call. - But the change resulted into `nil` being returned when there was no change in the attribute value. - This commit corrects the behavior to return true if there is no change in attribute value. This is same as previous behavior of Rails 4.2 plus benefit of no additional SQL call. - Fixes #26593.
* | | Always store errors details information with symbolsRafael Mendonça França2016-09-191-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the association is autosaved we were storing the details with string keys. This was creating inconsistency with other details that are added using the `Errors#add` method. It was also inconsistent with the `Errors#messages` storage. To fix this inconsistency we are always storing with symbols. This will cause a small breaking change because in those cases the details could be accessed as strings keys but now it can not. The reason that we chose to do this breaking change is because `#details` should be considered a low level object like `#messages` is. Fix #26499. [Rafael Mendonça França + Marcus Vieira]
* | | Clear attribute changes after handling lockingJakob Skjerning2016-09-141-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this the changes to the lock version column will stick around even after `touch` returns. Before: model.touch model.changes # => {"lock_version"=>[0, "1"]} After: model.touch model.changes # {}
* | | 5-0-backport: activerecord/mysql2: Avoid setting @connection to nil, just ↵Dylan Thacker-Smith2016-09-131-0/+5
|/ / | | | | | | | | | | | | | | | | | | close it (#26473) * activerecord/mysql2: Avoid setting @connection to nil, just close it Backport of https://github.com/rails/rails/pull/26434 * Add a CHANGELOG entry
* | Attempt to maintain encoding for arrays of strings with PGSean Griffin2016-08-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I still think that this is something that should be handled in the pg gem, but it's not going to end up happening there so we'll do it here instead. Once we bump to pg 0.19 we can pass the encoding to the `encode` method instead. This issue occurs because C has no concept of encoding (or strings, really). The bytes that we pass here when sending the value to the database will always be interpreted as whatever encoding the connection is currently configured to use. That means that roundtripping to the database will lose no information However, after assigning we round trip through our type system without hitting the database. The only way that we can do the "correct" thin here would be to actually give a reference to the connection to the array type and have it check the current value of the connection's encoding -- which I'm strongly opposed to. We could also pass in the encoding when it's constructed, but since that can change independently of the type I'm not a huge fan of that either. This feels like a reasonable middle ground, where if we have an array of strings we simply use the encoding of the string we're given. Fixes #26326.
* | Ensure that inverse associations are set before running callbacksSean Griffin2016-08-311-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a parent association was accessed in an `after_find` or `after_initialize` callback, it would always end up loading the association, and then immediately overwriting the association we just loaded. If this occurred in a way that the parent's `current_scope` was set to eager load the child, this would result in an infinite loop and eventually overflow the stack. For records that are created with `.new`, we have a mechanism to perform an action before the callbacks are run. I've introduced the same code path for records created with `instantiate`, and updated all code which sets inverse instances on newly loaded associations to use this block instead. Fixes #26320.
* | Don't unnecessarily load a belongs_to when saving.James Coleman2016-08-261-0/+5
| | | | | | | | | | | | | | | | Previously, if the the association was previously loaded and then the foreign key changed by itself, a #save call would trigger a load of the new associated record during autosave. This is unnecessary and the autosave code (in that case) didn't use the loaded record anyways.
* | Remove the SchemaDumper options and change the default behaviorRafael Mendonça França2016-08-221-3/+1
| | | | | | | | | | Now the schema dumper by default doesn't align the types and arguments in the ruby format anymore.
* | Merge pull request #25675 from TimPetricola/schema-no-standardized-column-widthsRafael Mendonça França2016-08-191-0/+6
|\ \ | | | | | | | | | Option not to line up column attributes in schema.rb
| * | Option not to line up column types and attributes in schema.rbTim Petricola2016-08-171-3/+9
| | |
* | | Add chengelog entry to #25976Rafael Mendonça França2016-08-191-0/+7
| | | | | | | | | | | | [Rafael Mendonça França + Robin Dupret]
* | | Merge pull request #26154 from ↵Rafael Mendonça França2016-08-191-0/+32
|\ \ \ | | | | | | | | | | | | | | | | | | | | kamipo/remove_text_default_treated_as_empty_string Remove text default treated as an empty string in non-strict mode
| * | | Remove text default treated as an empty string in non-strict modeRyuta Kamizono2016-08-191-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. If strict mode is not in effect, MySQL inserts adjusted values for invalid or missing values and produces warnings. ```ruby def test_mysql_not_null_defaults_non_strict using_strict(false) do with_mysql_not_null_table do |klass| record = klass.new assert_nil record.non_null_integer assert_nil record.non_null_string assert_nil record.non_null_text assert_nil record.non_null_blob record.save! record.reload assert_equal 0, record.non_null_integer assert_equal "", record.non_null_string assert_equal "", record.non_null_text assert_equal "", record.non_null_blob end end end ``` It is inconsistent with other types that only text/blob defaults treated as an empty string. This commit fixes the inconsistency.
* | | | Merge pull request #26089 from travisoneill/sqlite_rollback_fixRafael Mendonça França2016-08-191-3/+11
|\ \ \ \ | |/ / / |/| | | | | | | Sqlite3 Migration Error Fixed (issue #26087)
| * | | Added nil case handling to allow rollback migration in case oftravis.h.oneill@gmail.com2016-08-171-3/+11
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid column type /activerecord/lib/active_record/connection_adapters /abstract/schema_definitions.rb:306 type = type.to_sym Changed to the following to handle nil case: type = type.to_sym if type Added regression test for this case: /activerecord/test/cases/migration_test.rb:554 if current_adapter?(:SQLite3Adapter) def test_allows_sqlite3_rollback_on_invalid_column_type Person.connection.create_table :something, force: true do |t| t.column :number, :integer t.column :name, :string t.column :foo, :bar end assert Person.connection.column_exists?(:something, :foo) assert_nothing_raised { Person.connection.remove_column :something, :foo, :bar } assert !Person.connection.column_exists?(:something, :foo) assert Person.connection.column_exists?(:something, :name) assert Person.connection.column_exists?(:something, :number) ensure Person.connection.drop_table :something, if_exists: true end end
* / / Deprecate `sanitize_conditions`. Use `sanitize_sql` insteadRyuta Kamizono2016-08-181-0/+4
|/ / | | | | | | Because `sanitize_conditions` protected method is only used in one place.
* | Fix count which would sometimes force a DISTINCTMaxime Lapointe2016-08-161-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current behaviour of checking if there is a LEFT OUTER JOIN arel node to detect if we are doing eager_loading is wrong. This problem wasn't frequent before as only some pretty specific cases would add a LEFT OUTER JOIN arel node. However, the recent new feature left_outer_joins also add this node and made this problem happen frequently. Since in the perform_calculation function, we don't have access to eager_loading information, I had to extract the logic for the distinct out to the calculate method. As I was in the file for left_outer_join tests, I fixed a few that had bugs and I replaced some that were really weak with something that will catch more issues. In relation tests, the first test I changed would have failed if it had validated the hash returned by count instead of just checking how many pairs were in it. This is because this merge of join currently transforms the join node into an outer join node, which then made count do a distinct. So before this change, the return was {1=>1, 4=>1, 5=>1}.
* | When calling association.find RecordNotFound is now raised with the same ↵Michel Pigassou2016-08-131-0/+5
| | | | | | | | argument as when we do it in Record.find (primary_key, id and model).
* | Pass over changelogs [ci skip]Vipul A M2016-08-101-2/+5
| |
* | Don't assume all hashes are from multiparameter assignment in `composed_of`Sean Griffin2016-08-051-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So this bug is kinda funky. The code path is basically "if we weren't passed an instance of the class we compose to, and we have a converter, call that". Ignoring the hash case for a moment, everything after that was roughly intended to be the "else" clause, meaning that we are expected to have an instance of the class we compose to. Really, we should be blowing up in that case, as we can give a much better error message than what they user will likely get (e.g. `NameError: No method first for String` or something). Still, Ruby is duck typed, so if the object you're assigning responds to the same methods as the type you compose to, knock yourself out. The hash case was added in 36e9be8 to remove a bunch of special cased code from multiparameter assignment. I wrongly assumed that the only time we'd get a hash there is in that case. Multiparameter assignment will construct a very specific hash though, where the keys are integers, and we will have a set of keys covering `1..part.size` exactly. I'm pretty sure this could actually be passed around as an array, but that's a different story. Really I should convert this to something like `class MultiParameterAssignment < Hash; end`, which I might do soon. However for a change that I'm willing to backport to 4-2-stable, this is what I want to go with for the time being. Fixes #25978
* | Add the TABLE_SCHEMA condition to the SELECT statement in table_comment (#25945)Takeshi AKIMA2016-07-271-0/+4
| | | | | | [Rafael Mendonça França + Takeshi AKIMA]
* | Whoops, forgot the changelog entry for the previous commitSean Griffin2016-07-251-0/+5
| |
* | Merge pull request #25849 from suginoy/fix_merge_in_scopeRafael Mendonça França2016-07-201-0/+4
|\ \ | | | | | | | | | Fix the calling `merge` method at first in a scope
| * | Fix the calling `merge` method at first in a scopesuginoy2016-07-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changing the order of method chaining `merge` and other query method such as `joins` should produce the same result. ```ruby class Topic < ApplicationRecord scope :safe_chaininig, -> { joins(:comments).merge(Comment.newest) } scope :unsafe_chaininig, -> { merge(Comment.newest).joins(:comments) } #=> NoMethodError end ```
* | | Fixes multiparameter attributes conversion with time_zone_aware_attributes ↵alpaca-tc2016-07-191-0/+4
|/ / | | | | | | and invalid params
* | CHANGELOG for https://github.com/rails/rails/pull/25257 [ci skip]Prathamesh Sonpatki2016-07-171-2/+4
| | | | | | | | - Also minor weekly CHANGELOG cleanup.
* | Add newline between each migration in `structure.sql`Grey Baker2016-07-141-0/+7
| | | | | | | | | | | | Keeps schema migration inserts as a single commit, so we still get all of the benefits of https://github.com/rails/rails/commit/42dd2336b31a8d98776d039a2b9fd7f834156a78, but allows for easier git diff-ing. Fixes #25504.
* | adds support for limits in batch processingXavier Noria2016-07-131-0/+15
| |
* | Always prefer class types to query types when casting `group`Sean Griffin2016-07-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | When `group` is used in combination with any calculation method, the resulting hash uses the grouping expression as the key. Currently we're incorrectly always favoring the type reported by the query, instead of the type known by the class. This causes differing behavior depending on whether the adaptor actually gives proper types with the query or not. After this change, the behavior will be the same on all adaptors -- we see if we know the type from the class, fall back to the type from the query, and finally fall back to the identity type. Fixes #25595
* | Cleanup CHANGELOGs [ci skip]Prathamesh Sonpatki2016-07-091-7/+7
| | | | | | | | | | | | - Cleanup Active Record CHANGELOG. - Add missing CHANGELOG for https://github.com/rails/rails/pull/25688. - Clarify that assets requests logging is suppressed.
* | fix to_param to maximize contentRob Biedenharn2016-07-081-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation states that parameter values longer than 20 characters will be truncated by words, but the example shows that a parameter based on "David Heinemeier Hansson" (with id: 125) becomes "125-david" when "David Heinemeier".length == 16 so why so short? The answer lies in the use of the #truncate option omission: nil which seems to have been intended to mean "nothing", but which actually causes the default string "..." to be used. This causes #truncate to cleave words until the "..." can be added and still remain within the requested size of 20 characters. The better option is omission: '' (which is probably what was originally intended). Furthermore, since the use of #parameterize will remove non-alphanumeric characters, we can maximize the useful content of the output by calling parameterize first and then giving truncate a separator: /-/ rather than a space.
* | Re-check that the connection is still stale before we reap itMatthew Draper2016-07-061-0/+7
| | | | | | | | | | | | | | A concurrent thread may have also detected it to be stale, and already released (or even reassigned) it by now. Fixes #25585