1. 18 2月, 2015 1 次提交
  2. 13 2月, 2015 1 次提交
  3. 04 2月, 2015 1 次提交
    • S
      Correct errors in counter cache updating · 23bb8d77
      Sean Griffin 提交于
      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.
      23bb8d77
  4. 31 1月, 2015 1 次提交
  5. 28 1月, 2015 4 次提交
    • H
      Provide a better error message on :required association · 9a6c6c6f
      Henrik Nygren 提交于
      Fixes #18696.
      9a6c6c6f
    • S
      Remove Relation#bind_params · b06f64c3
      Sean Griffin 提交于
      `bound_attributes` is now used universally across the board, removing
      the need for the conversion layer. These changes are mostly mechanical,
      with the exception of the log subscriber. Additional, we had to
      implement `hash` on the attribute objects, so they could be used as a
      key for query caching.
      b06f64c3
    • S
      Use an `Attribute` object to represent a bind value · 6c235dd9
      Sean Griffin 提交于
      The column is primarily used for type casting, which we're trying to
      separate from the idea of a column. Since what we really need is the
      combination of a name, type, and value, let's use the object that we
      already have to represent that concept, rather than this tuple. No
      consumers of the bind values have been changed, only the producers
      (outside of tests which care too much about internals). This is
      *finally* possible since the bind values are now produced from a
      reasonable number of lcoations.
      6c235dd9
    • S
      Don't rely on the internal representation of join values · 102a5272
      Sean Griffin 提交于
      I'm going to be extracting this logic into a clause class, things need
      to go through a method and not access the values hash directly.
      102a5272
  6. 27 1月, 2015 3 次提交
    • S
      Go through normal `where` logic in `AssociationScope` · 6a7ac40d
      Sean Griffin 提交于
      This removes the need to duplicate much of the logic in `WhereClause`
      and `PredicateBuilder`, simplifies the code, removes the need for the
      connection adapter to be continuously passed around, and removes one
      place that cares about the internal representation of `bind_values`
      
      Part of the larger refactoring to change how binds are represented
      internally
      
      [Sean Griffin & anthonynavarre]
      6a7ac40d
    • S
      Improve consistency of counter caches updating in memory · 1152219f
      Sean Griffin 提交于
      When we made sure that the counter gets updated in memory, we only did
      it on the has many side. The has many side only does the update if the
      belongs to cannot. The belongs to side was updated to update the counter
      cache (if it is able). This means that we need to check if the
      belongs_to is able to update in memory on the has_many side.
      
      We also found an inconsistency where the reflection names were used to
      grab the association which should update the counter cache. Since
      reflection names are now strings, this means it was using a different
      instance than the one which would have the inverse instance set.
      
      Fixes #18689
      
      [Sean Griffin & anthonynavarre]
      1152219f
    • S
      Move flattening records added to an association farther out · 025187d9
      Sean Griffin 提交于
      There are many ways that things end up getting passed to `concat`. Not
      all of those entry points called `flatten` on their input. It seems that
      just about every method that is meant to take a single record, or that
      splats its input, is meant to also take an array. `concat` is the
      earliest point that is common to all of the methods which add records to
      the association. Partially fixes #18689
      025187d9
  7. 26 1月, 2015 4 次提交
  8. 25 1月, 2015 1 次提交
    • S
      Don't rely on relation mutability when building through associations · c80487eb
      Sean Griffin 提交于
      Specifically, the issue is relying on `where_unscoping` mutating the
      where values. It does not, however, mutate the bind values, which could
      cause an error under certain circumstances. This was not exposed by the
      tests, since the only place which would have been affected is unscoping
      a boolean, which doesn't go through prepared statements. I had a hard
      time getting better test coverage to demonstrate the issue.
      
      This in turn, caused `merge` to go through proper logic, and try to
      clear out the binds associated with the unscoped relation, which then
      exposed a source of `nil` for the columns, as binds weren't expanding
      `{ "posts.id" => 1 }` to `{ "posts" => { "id" => 1 } }`. This has been
      fixed.
      
      The bulk of `create_binds` needed to be moved to a separate method,
      since the dot notation should not be expanded recursively.
      
      I'm pretty sure this removes a subtle quirk that a ton of code in
      `Relation::Merger` is working around, and I suspect that code can be
      greatly simplified. However, unraveling that rats nest is no small task.
      c80487eb
  9. 04 1月, 2015 4 次提交
  10. 03 1月, 2015 16 次提交
    • C
      Deprecate `false` as the way to halt AR callbacks · bb78af73
      claudiob 提交于
      Before this commit, returning `false` in an ActiveRecord `before_` callback
      such as `before_create` would halt the callback chain.
      
      After this commit, the behavior is deprecated: will still work until
      the next release of Rails but will also display a deprecation warning.
      
      The preferred way to halt a callback chain is to explicitly `throw(:abort)`.
      bb78af73
    • E
      Cleanup methods, missing spacing and missing nodocs · b0d87a72
      eileencodes 提交于
      Add missing nodoc's
      Change `assoc_klass` argument name to `association_klass`
      Change `prev_reflection` argument name to `previous_reflection`
      Change `prev` to `previous_reflection` in `#get_chain`
      Switch use of `refl` and `reflection` in `#get_chain` so main parameter
      is not abbreviated.
      Add missing space in `#add_constraints`
      b0d87a72
    • E
      Move `#type_caster` to alias tracker initialize · 39abe835
      eileencodes 提交于
      This moves the `#type_caster` from the `aliased_table_for` and into the
      initialize of the `alias_tracker`.
      39abe835
    • E
      Add `#all_includes` method to reflections · 96e277c0
      eileencodes 提交于
      `yield` instead of relying on checking if the reflection is equal to the
      `chain_head`.
      96e277c0
    • E
      Initialze `#alias_tracker` with base table name · 0408e212
      eileencodes 提交于
      Instead of initializing an empty connection use the base table name
      instead. Split up and refactor `#create` to be 2 methods `#create` and
      `#create_with_joins`. Removes the need to update the count by 1 on
      initialzing a JoinDependency.
      0408e212
    • E
      Move `alias_candiate` into `AbstractReflection` · 16fafd65
      eileencodes 提交于
      This moves `alias_candidate` out of the `ReflectionProxy` and into the
      `AbstractReflection` so it is shared by all reflections. Change
      `alias_name` to a method and and remove assignment in `#get_chain`.
      16fafd65
    • E
      Pass `connection` rather than `alias_tracker` · cc9b813a
      eileencodes 提交于
      After the refactorings we're only using the connection and not the alias
      tracker anymore. This builds on commit 18019.
      
      Reuse the already available `@connection` to reduce the surface area of
      the alias tracker's API. We can then remove the `attr_reader` because
      the connection is already available.
      cc9b813a
    • E
      Assign the `#alias_name` to each reflection · f6729309
      eileencodes 提交于
      This makes the `#alias_name` more functional.
      f6729309
    • E
      Clean up / refactor new reflection classes · e9684d6c
      eileencodes 提交于
      Move `RuntimeReflection` and `PolymorphicReflect` into Reflection. This
      allows the methods to inherit from `ThroughReflection` and DRY up the
      methods by removing duplicates.
      e9684d6c
    • E
      Refactor `#get_chain` iteration to a linked list · 4d27d56c
      eileencodes 提交于
      The linked list lets us use a loop in `#add_constraints` and completely
      remove the need for indexing the iteration becasue we have access to the
      next item in the chain.
      4d27d56c
    • E
      Refactor `#get_chain` to remove need for `#construct_tables` · 17f6ca1e
      eileencodes 提交于
      By concatnating the `ReflectionProxy` with the `chain` we remove
      the need for `#construct_tables` because the `chain` is now in the
      correct order (order of the chain DOES matter).
      17f6ca1e
    • E
      Move `#alias_name` to `ReflectionProxy` class · 5b0b3cce
      eileencodes 提交于
      Putting the `#alias_name` into ReflectionProxy means we don't have to
      cache the `#alias_name` globally anymore - it's not cached per query.
      5b0b3cce
    • E
      Clean up assignments in `#add_constraints` · 092171da
      eileencodes 提交于
      `is_first_chain`, `items` and `klass` are no longer beneficial and can
      be called directly instead of via their assignments - because they are
      each only used once.
      092171da
    • E
      Refactor construct_tables method · 07668269
      eileencodes 提交于
      Move method structure into reflection classes for accessibly on each
      reflection rather than by traversing the chain.
      07668269
    • E
      Add RuntimeReflection for recursive access to chain · 69d05ae3
      eileencodes 提交于
      The `RuntimeReflection` class allows the reflection to be accessed at
      runtime - then we always know which reflection we are accessing in the
      chain. The `#get_chain` method then allows us to recursively access the
      chain through the `RuntimeReflection`.
      69d05ae3
    • E
      Add PolymorphicReflection and constraints method · 08acb4bc
      eileencodes 提交于
      `#constraints` builds a flattened version of `scope_chain` to
      allow it to be accessible without requiring an index when iterating
      over the `scope_chain`
      08acb4bc
  11. 02 1月, 2015 1 次提交
  12. 31 12月, 2014 1 次提交
  13. 30 12月, 2014 2 次提交