aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
Commit message (Collapse)AuthorAgeFilesLines
* Specifically talking about Rake the library [ci skip]Zachary Scott2014-06-131-2/+1
|
* PG arrays should type cast user inputSean Griffin2014-06-131-4/+8
| | | | | | We guarantee that `model.value` does not change after `model.save && model.reload`. This requires type casting user input for non-string types.
* Merge pull request #15677 from sgrif/sg-less-imperative-pkMatthew Draper2014-06-131-3/+4
|\ | | | | Use a conditional rather than early return in `id`
| * Use a conditional rather than early return in `id`Sean Griffin2014-06-121-3/+4
| |
* | Defer to super, rather than re-implementing Object#hashSean Griffin2014-06-121-1/+5
|/
* Fix performance regression on preloading HABTM associationsSean Griffin2014-06-122-1/+2
| | | | | | | | | | | We'd spend a lot of time calling `hash` and `eql?` on the join model, which has no primary key. Calling `id` with no primary key is a really slow way to get back `nil`, so we can improve the performance there. However, even with the escape clause, we *still* weren't getting high enough performance, as we were checking the primary key too much. `hash` will always return `nil.hash` for records with no id, and `==` will always return `false`. We can optimize those cases in the HABTM join model.
* Merge pull request #15394 from ↵Yves Senn2014-06-122-1/+7
|\ | | | | | | | | | | | | | | | | morgoth/fix-automatic-maintaining-test-schema-for-sql-format ActiveRecord::Migration.maintain_test_schema! doesn't work with structure.sql Conflicts: activerecord/CHANGELOG.md
| * Fixed automatic maintaining test schema to properly handle sql structure ↵Wojciech Wnętrzak2014-06-122-1/+7
| | | | | | | | | | | | | | | | | | schema format. Additionally: * It changes `purge` task on `sqlite3` adapter to recreate database file, to be consistent with other adapters. * Adds `purge` step when loading from `schema.rb`
* | Merge pull request #15647 from sgrif/sg-unused-requireYves Senn2014-06-121-2/+0
|\ \ | | | | | | Remove unused require
| * | Remove unused requireSean Griffin2014-06-111-2/+0
| | | | | | | | | | | | We're not longer using `ipaddr` in schema dumper
* | | Pluck should work with columns of the same name from different tablesSean Griffin2014-06-111-3/+1
|/ / | | | | | | | | | | | | | | The column name given by the adapter doesn't include the table namespace, so going through the hashed version of the result set causes overridden keys. Fixes #15649
* | Merge pull request #15582 from sgrif/sg-timestampsRafael Mendonça França2014-06-111-3/+5
|\ \ | | | | | | Refactor determination of max updated timestamp
| * | Refactor determination of max updated timestampSean Griffin2014-06-091-3/+5
| | | | | | | | | | | | `[].max # => nil`
* | | Merge pull request #15630 from eileencodes/refactor-join-keys-on-add_constraintsMatthew Draper2014-06-122-12/+20
|\ \ \ | | | | | | | | begin refactoring add_constraints by moving join keys
| * | | begin refactoring add_constraints by moving join keyseileencodes2014-06-102-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add_constraints is complicated and difficult to read. This is the beginning of a long process of refactoring this code. First step: moved the join keys out of AssociationScope and into reflection. We then don't need to call `reflection` because now reflection is `self`. `foreign_key` must be named something else because reflection already has a `foreign_key` method and when passed into `JoinKeys` it was getting the wrong assignment. `reflection_foreign_key` seemed to be an appropriate name. I also named `key` `reflection_key` to match `reflection_foreign_key`.
* | | | Merge pull request #15429 from sgrif/sg-rm-cached-attributesRafael Mendonça França2014-06-111-38/+11
|\ \ \ \ | | | | | | | | | | rm cached attributes
| * | | | rm cached attributesSean Griffin2014-06-111-38/+11
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original patch that added this concept can be found [here](https://web.archive.org/web/20090601022739/http://dev.rubyonrails.org/ticket/9767). The current default behavior is to cache everything except serialized columns, unless the user specified otherwise. If anyone were to specify otherwise, many types would actually be completely broken. Still, the method is left in place with a deprecation warning in case anyone is actually still calling this method.
* | | | Add has_one? docs [skip ci]Arthur Neves2014-06-111-0/+1
| | | |
* | | | Merge pull request #15637 from akshay-vishnoi/delete-deprecated-methodSantiago Pastorino2014-06-111-4/+0
|\ \ \ \ | | | | | | | | | | Remove deprecation warning
| * | | | Remove deprecation warningAkshay Vishnoi2014-06-111-4/+0
| |/ / /
* | | | Merge pull request #15638 from sgrif/sg-column-typesRafael Mendonça França2014-06-111-6/+10
|\ \ \ \ | | | | | | | | | | Ensure `column_types` returns a type object, and not a column
| * | | | Ensure `column_types` returns a type object, and not a columnSean Griffin2014-06-111-6/+10
| |/ / /
* / / / Remove YAML serialization workaround for columnsSean Griffin2014-06-111-6/+2
|/ / / | | | | | | | | | | | | We are no longer including column objects in YAML serialization, thanks to https://github.com/rails/rails/pull/15621
* | | Merge pull request #15621 from sgrif/sg-column-type-decorationsRafael Mendonça França2014-06-102-2/+1
|\ \ \ | | | | | | | | No need to decorate columns twice
| * | | No need to decorate columns twiceSean Griffin2014-06-102-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We never want result types to override column types, and `decorate_columns` can only affect column types. No need to go through the decoration multiple times, we can just exclude the column types from the result types instead.
* | | | remove deprecation call while initializing `ClassCache` objectKuldeep Aggarwal2014-06-111-7/+1
| | | |
* | | | Remove deprecated method ActiveRecord::Base.quoted_locking_columnAkshay Vishnoi2014-06-101-6/+0
|/ / /
* | | Keep the types of virtual columns after yaml serializationSean Griffin2014-06-103-2/+18
| | | | | | | | | | | | | | | On MySQL and PostgreSQL, the adapter does not type cast virtual columns for us.
* | | Merge pull request #15607 from sgrif/sg-array-type-castRafael Mendonça França2014-06-103-34/+28
|\ \ \ | | | | | | | | Inline PG array type casting helper
| * | | Inline PG array type casting helperSean Griffin2014-06-103-34/+28
| | | |
* | | | ActiveRecord::FinderMethods.find passes proc parameter #15382James Yang2014-06-101-1/+1
| | | |
* | | | Use HasAndBelongsToMany instead of HABTMArthur Neves2014-06-092-2/+2
| | | |
* | | | reuse available collection? check instead of macroeileencodes2014-06-093-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reflection has an available method that is used to check if the reflection is a collection. Any :has_many macro is considered a collection and `collection?` should be used instead of `macro == :has_many`.
* | | | Merge pull request #15596 from eileencodes/add-has_one-method-and-reuseRafael Mendonça França2014-06-095-5/+9
|\ \ \ \ | | | | | | | | | | add has_one? method and reuse instead of checking macro
| * | | | add has_one? method and reuse instead of checking macroeileencodes2014-06-095-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of checking for `macro == :has_one` throughout the codebase we can create a `has_one?` method to match the `belongs_to?`, `polymorphic?` and other methods.
* | | | | Merge pull request #15595 from eileencodes/abstract-away-habtm-macroAaron Patterson2014-06-092-2/+9
|\ \ \ \ \ | |/ / / / |/| | | | Abstract away use of HABTM macro
| * | | | Abstract away use of HABTM macroeileencodes2014-06-092-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By having the `:has_and_belongs_to_many` macro in the `@collection` we are punishing `:has_many` associations because it has to allocate the array and check the macro. @collection is returned to `macro == :has_many` and a new reflection class `HABTMReflection` is created to handle this case instead.
* | | | | Timestamp values should be present on callbacksRafael Mendonça França2014-06-091-1/+1
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | This reverts commit dd3ea17191e316aeebddaa7b176f6cfeee7a6365 and add a regression test. Fixes #15418
* | | | Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-0914-31/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* | | | Merge pull request #15586 from sgrif/sg-identity-typeRafael Mendonça França2014-06-091-1/+1
|\ \ \ \ | | | | | | | | | | Use an actual identity type in AR::Result#identity_type
| * | | | Use an actual identity type in AR::Result#identity_typeSean Griffin2014-06-091-1/+1
| | |/ / | |/| | | | | | | | | | | | | | We should be able to rely on this object implenting the full type interface.
* | | | Merge pull request #15591 from sgrif/sg-rm-write-attributeRafael Mendonça França2014-06-099-58/+52
|\ \ \ \ | | | | | | | | | | Make `_before_type_cast` actually be before type cast
| * | | | Make `_before_type_cast` actually be before type castSean Griffin2014-06-099-58/+52
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The following is now true for all types, all the time - `model.attribute_before_type_cast == given_value` - `model.attribute == model.save_and_reload.attribute` - `model.attribute == model.dup.attribute` - `model.attribute == YAML.load(YAML.dump(model)).attribute` - Removes the remaining types implementing `type_cast_for_write` - Simplifies the implementation of time zone aware attributes - Brings tz aware attributes closer to being implemented as an attribute decorator - Adds additional point of control for custom types
* | / / Do not try to set the foreign_key again on has_many throughRafael Mendonça França2014-06-091-1/+1
| |/ / |/| | | | | | | | | | | | | | | | | Integration tests are inside protected_attributes test suite. Fixes #15496 Fixes rails/protected_attributes#35
* | | Remove a long gone :order option from has_one's valid_options.thedarkone2014-06-091-1/+1
|/ /
* | Merge pull request #15558 from sgrif/sg-rename-propertyRafael Mendonça França2014-06-072-8/+8
|\ \ | | | | | | | | | | | | | | | | | | | | | Rename `property` to `attribute` Conflicts: activerecord/lib/active_record/attribute_methods/serialization.rb activerecord/lib/active_record/base.rb
| * | Rename `property` to `attribute`Sean Griffin2014-06-073-9/+9
| | | | | | | | | | | | For consistency with https://github.com/rails/rails/pull/15557
* | | Merge pull request #15546 from sgrif/sg-lazy-decoratorsRafael Mendonça França2014-06-075-16/+60
|\ \ \ | | | | | | | | Don't query the database schema when calling `serialize`
| * | | Don't query the database schema when calling `serialize`Sean Griffin2014-06-075-16/+60
| | | | | | | | | | | | | | | | | | | | | | | | We need to decorate the types lazily. This is extracted to a separate API, as there are other refactorings that will be able to make use of it, and to allow unit testing the finer points more granularly.
* | | | Merge pull request #15561 from sgrif/sg-time-zone-aware-arraysRafael Mendonça França2014-06-071-1/+11
|\ \ \ \ | | | | | | | | | | Ensure time zones don't change after round trip with array columns