aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | 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-094-23/+15
| |/ / / |/| | | | | | | | | | | | | | | | | | | | | | | This reverts commit dd3ea17191e316aeebddaa7b176f6cfeee7a6365 and add a regression test. Fixes #15418
* | | | Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-0926-132/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 #15587 from sgrif/sg-remove-workaroundRafael Mendonça França2014-06-091-15/+8
|\ \ \ \ | | | | | | | | | | Remove workaround for non-lazy serialize in tests
| * | | | Remove workaround for non-lazy serialize in testsSean Griffin2014-06-091-15/+8
| |/ / / | | | | | | | | | | | | `serialize` is now lazy, so the workaround is no longer needed.
* | | | Merge pull request #15591 from sgrif/sg-rm-write-attributeRafael Mendonça França2014-06-0915-64/+64
|\ \ \ \ | | | | | | | | | | Make `_before_type_cast` actually be before type cast
| * | | | Make `_before_type_cast` actually be before type castSean Griffin2014-06-0915-64/+64
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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
|/ /
* | fix test cases after #15558 merge to master.Kuldeep Aggarwal2014-06-071-3/+3
| |
* | Merge pull request #15558 from sgrif/sg-rename-propertyRafael Mendonça França2014-06-077-25/+25
|\ \ | | | | | | | | | | | | | | | | | | | | | 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-078-26/+26
| | | | | | | | | | | | For consistency with https://github.com/rails/rails/pull/15557
* | | Merge pull request #15546 from sgrif/sg-lazy-decoratorsRafael Mendonça França2014-06-077-16/+179
|\ \ \ | | | | | | | | Don't query the database schema when calling `serialize`
| * | | Don't query the database schema when calling `serialize`Sean Griffin2014-06-077-16/+179
| | | | | | | | | | | | | | | | | | | | | | | | 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-072-1/+13
|\ \ \ \ | | | | | | | | | | Ensure time zones don't change after round trip with array columns
| * | | | Ensure time zones don't change after round trip with array columnsSean Griffin2014-06-072-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The times would be equivalent, even if they were in different time zones. E.g. 12:00 UTC == 5:00 PDT
* | | | | Merge pull request #15562 from sgrif/sg-double-type-cast-dirtyRafael Mendonça França2014-06-075-25/+27
|\ \ \ \ \ | | | | | | | | | | | | Do not type cast twice on attribute assignment
| * | | | | Do not type cast twice on attribute assignmentSean Griffin2014-06-075-25/+27
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The definition of `write_attribute` in dirty checking ultimately leads to the columns calling `type_cast` on the value to perform the comparison. However, this is a potentially expensive computation that we cache when it occurs in `read_attribute`. The only case that we need the non-type-cast form is for numeric, so we pass that through as well (something I'm looking to remove in the future). This also reduces the number of places that manually access various stages in an attribute's type casting lifecycle, which will aid in one of the larger refactorings that I'm working on.
* | | | | Merge pull request #15564 from sgrif/sg-remove-dead-codeRafael Mendonça França2014-06-071-7/+2
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove dead branch when restoring ID within a transaction Conflicts: activerecord/lib/active_record/transactions.rb
| * | | | | Remove dead branch when restoring ID within a transactionSean Griffin2014-06-071-7/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no way to have an instance of an Active Record model where `has_attribute?(self.class.primary_key)` returns false. The record is always initialized in such a way that `@raw_attributes` will have an id key with nil for the value.
* | | | | | Move conditionals about freezing closer to the definition of `freeze`Sean Griffin2014-06-072-4/+8
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduces the number of places that care about the internals of how we store and type cast attributes. We do not need to go through the dup/freeze dance, as you couldn't have saved a frozen new record anyway, and that is the only time we would end up modifying the frozen hash.
* / / / / Remove duplicated `@raw_attributes.keys`Sean Griffin2014-06-072-3/+3
|/ / / / | | | | | | | | | | | | | | | | Reduces the number of things outside of attribute methods that cares about the details of how we store and type cast attributes
* | | | Merge pull request #15557 from sgrif/sg-specify-time-zoneMatthew Draper2014-06-081-5/+10
|\ \ \ \ | | | | | | | | | | Specify a time zone when testing TZ aware attributes
| * | | | Don't rely on `Time.current` in testsSean Griffin2014-06-071-5/+10
| | |/ / | |/| | | | | | | | | | Millisecond inequality causes failures on Travis
* / | | changelog for #15556 and credit @kuldeepaggarwal [Kuldeep Aggarwal]Yves Senn2014-06-072-2/+6
|/ / / | | | | | | | | | | | | | | | This is a follow up to #15556 @kuldeepaggarwal did submit this patch way back (#13624).
* | | Merge pull request #15556 from sgrif/sg-time-zone-aware-arraysYves Senn2014-06-072-1/+29
|\ \ \ | | | | | | | | Add array support when time zone aware attributes are enabled
| * | | Add array support when time zone aware attributes are enabledSean Griffin2014-06-072-1/+29
| | | |
* | | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2014-06-071-3/+4
|\ \ \ \
| * | | | [ci skip] remove double "in your"schneems2014-06-041-1/+1
| | | | |
| * | | | [ci skip] less derogatory explanation of defaultsschneems2014-06-021-2/+3
| | | | |
| * | | | [ci skip] fix "note" syntaxschneems2014-06-021-1/+1
| | |_|/ | |/| |
* | | | Merge pull request #15542 from Gaurav2728/gaurav-remove_shutdown_linkArthur Nogueira Neves2014-06-061-4/+4
|\ \ \ \ | | | | | | | | | | remove rubyforge.org that was shut down [ci skip]
| * | | | remove rubyforge.org that was shut down [ci skip]Gaurav Sharma2014-06-061-4/+4
| | |_|/ | |/| |
* | | | Removed unused `klass` definitions from typesSean Griffin2014-06-066-21/+0
| |_|/ |/| | | | | | | | Only `Date` and `Time` are handled.
* | | Merge pull request #15552 from sgrif/sg-remove-klass-special-caseRafael Mendonça França2014-06-062-4/+7
|\ \ \ | | | | | | | | Remove composed_of special case from multi-parameter attributes
| * | | Remove composed_of special case from multi-parameter attributesSean Griffin2014-06-062-4/+7
| |/ / | | | | | | | | | | | | As we move towards removing the `klass` method from `column`, the else clause as it stands right now will become the only case.
* / / Don't mess with `_before_type_cast` for numeric typesSean Griffin2014-06-062-9/+9
|/ /
* | Merge pull request #15533 from sgrif/sg-missing-schema-testsYves Senn2014-06-061-0/+29
|\ \ | | | | | | Add missing test cases for schema dumping defaults
| * | Add missing test cases for schema dumping defaultsSean Griffin2014-06-061-0/+29
| | |
* | | credit JoseLuis Torres for #15051. [JoseLuis Torres]Yves Senn2014-06-061-1/+1
| | | | | | | | | | | | [ci skip]
* | | `ActiveRecord::SchemaMigration` has no primary key.Yves Senn2014-06-063-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this patch, using `ActiveRecord::Base.primary_key_prefix_type` with `:table_name_with_underscore` would change the `SchemaMigration` model to have a primary key. This resulted in broken queries for PG because it tried to return the inserted PK (which does not exist). Closes #15051. Closes #15419.
* | | test refactor, don't hardcode default for `table_name_prefix`.Yves Senn2014-06-061-1/+2
| | |
* | | test refactor, don't hardcode `primary_key_prefix_type` default.Yves Senn2014-06-061-0/+3
| | | | | | | | | | | | /cc @zuhao
* | | serialized Type should delegate `type_cast_for_write` to underlying TypeYves Senn2014-06-062-1/+36
|/ / | | | | | | | | | | | | This adds a regression test for #14411, which was fixed by #15503. Closes #14411 Closes #14595
* | Merge pull request #15503 from sgrif/sg-json-hstore-storageYves Senn2014-06-069-20/+29
|\ \ | | | | | | Bring type casting behavior of hstore/json in line with serialized
| * | Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-049-20/+29
| | | | | | | | | | | | | | | `@raw_attributes` should not contain the type-cast, mutable version of the value.
* | | `bin/rake db:migrate:status` works with legacy migration numbers.Yves Senn2014-06-065-4/+22
| | | | | | | | | | | | | | | | | | | | | The migration numbers were normalized different ways. This left the task output in an inconsistent state. Closes #15538.