- 10 6月, 2014 9 次提交
-
-
由 Arthur Neves 提交于
-
由 eileencodes 提交于
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`.
-
由 eileencodes 提交于
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.
-
由 eileencodes 提交于
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.
-
由 Rafael Mendonça França 提交于
This reverts commit dd3ea171 and add a regression test. Fixes #15418
-
由 Sean Griffin 提交于
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.
-
由 Sean Griffin 提交于
We should be able to rely on this object implenting the full type interface.
-
由 Rafael Mendonça França 提交于
Integration tests are inside protected_attributes test suite. Fixes #15496 Fixes rails/protected_attributes#35
-
由 Sean Griffin 提交于
- 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
-
- 09 6月, 2014 1 次提交
-
-
由 thedarkone 提交于
-
- 08 6月, 2014 3 次提交
-
-
由 Sean Griffin 提交于
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.
-
由 Sean Griffin 提交于
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.
-
由 Sean Griffin 提交于
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.
-
- 07 6月, 2014 12 次提交
-
-
由 Sean Griffin 提交于
Reduces the number of things outside of attribute methods that cares about the details of how we store and type cast attributes
-
由 Sean Griffin 提交于
The times would be equivalent, even if they were in different time zones. E.g. 12:00 UTC == 5:00 PDT
-
由 Yves Senn 提交于
This is a follow up to #15556 @kuldeepaggarwal did submit this patch way back (#13624).
-
由 Sean Griffin 提交于
For consistency with https://github.com/rails/rails/pull/15557
-
由 Sean Griffin 提交于
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.
-
由 Sean Griffin 提交于
-
由 Sean Griffin 提交于
Only `Date` and `Time` are handled.
-
由 Sean Griffin 提交于
As we move towards removing the `klass` method from `column`, the else clause as it stands right now will become the only case.
-
由 Sean Griffin 提交于
-
由 Rafael Mendonça França 提交于
This reverts commit be1db994, reversing changes made to 6680ee94. Reason: This changed a behavior where numeric attributes when receiving blank values didn't change its value.
-
由 Sean Griffin 提交于
-
由 Gaurav Sharma 提交于
-
- 06 6月, 2014 4 次提交
-
-
由 Yves Senn 提交于
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.
-
由 Yves Senn 提交于
This adds a regression test for #14411, which was fixed by #15503. Closes #14411 Closes #14595
-
由 Yves Senn 提交于
The migration numbers were normalized different ways. This left the task output in an inconsistent state. Closes #15538.
-
由 Sean Griffin 提交于
Whiny nils is no longer a thing, so we no longer need this optimization
-
- 05 6月, 2014 4 次提交
-
-
由 edogawaconan 提交于
BC era year is (astronomical year + 1) and starts from 1 BC.
-
由 Akshay Vishnoi 提交于
-
由 schneems 提交于
-
由 Yves Senn 提交于
Follow up to #15438 and #15502. /cc @sgrif
-
- 04 6月, 2014 7 次提交
-
-
由 Sean Griffin 提交于
For any type that is represented as a string and then type cast, we do not need separate regular expressions for the various types. No function will match this regex. User defined types *should* match this, so that the type object can decide what to do with the value.
-
由 Sean Griffin 提交于
`@raw_attributes` should not contain the type-cast, mutable version of the value.
-
由 Sean Griffin 提交于
-
由 Prathamesh Sonpatki 提交于
-
由 eileencodes 提交于
Reflection has a `belongs_to?` method. Instead of checking for `macro == :belongs_to` throughout the source reuse existing method. I also bumped `foreign_key_present?` method onto on line because the `belongs_to?` makes it shorter than other longer lines in the same class.
-
由 Lauro Caetano 提交于
than existing column. Fixes #15480.
-
由 Sean Griffin 提交于
The contract of `_field_changed?` assumes that the old value is always type cast. That is not the case for the value in `Column#default` as things are today. It appears there are other public methods that assume that `Column#default` is type cast, as well. The reason for this change originally was because the value gets put into `@raw_attributes` in initialize. This reverts to the old behavior on `Column`, and updates `initialize` to make sure that the values are in the right format.
-