1. 22 2月, 2019 2 次提交
  2. 19 2月, 2019 1 次提交
  3. 17 2月, 2019 2 次提交
  4. 15 2月, 2019 2 次提交
  5. 13 2月, 2019 1 次提交
    • R
      Fix `pluck` and `select` with custom attributes · 0ee96d13
      Ryuta Kamizono 提交于
      Currently custom attributes are always qualified by the table name in
      the generated SQL wrongly even if the table doesn't have the named
      column, it would cause an invalid SQL error.
      
      Custom attributes should only be qualified if the table has the same
      named column.
      0ee96d13
  6. 07 2月, 2019 1 次提交
    • R
      Fix `relation.create` to avoid leaking scope to initialization block and callbacks · 22360534
      Ryuta Kamizono 提交于
      `relation.create` populates scope attributes to new record by `scoping`,
      it is necessary to assign the scope attributes to the record and to find
      STI subclass from the scope attributes.
      
      But the effect of `scoping` is class global, it was caused undesired
      behavior that pollute all class level querying methods in initialization
      block and callbacks (`after_initialize`, `before_validation`,
      `before_save`, etc), which are user provided code.
      
      To avoid the leaking scope issue, restore the original current scope
      before initialization block and callbacks are invoked.
      
      Fixes #9894.
      Fixes #17577.
      Closes #31526.
      22360534
  7. 06 2月, 2019 1 次提交
  8. 08 12月, 2018 1 次提交
  9. 09 10月, 2018 1 次提交
    • R
      Generate delegation methods to named scope in the definition time · 136b738c
      Ryuta Kamizono 提交于
      The delegation methods to named scope are defined when `method_missing`
      is invoked on the relation.
      
      Since #29301, the receiver in the named scope is changed to the relation
      like others (e.g. `default_scope`, etc) for consistency.
      
      Most named scopes would be delegated from relation by `method_missing`,
      since we don't allow scopes to be defined which conflict with instance
      methods on `Relation` (#31179). But if a named scope is defined with the
      same name as any method on the `superclass` (e.g. `Kernel.open`), the
      `method_missing` on the relation is not invoked.
      
      To address the issue, make the delegation methods to named scope is
      generated in the definition time.
      
      Fixes #34098.
      136b738c
  10. 16 9月, 2018 1 次提交
  11. 11 9月, 2018 1 次提交
    • D
      Fixes #33610 · 5291044a
      Darwin D Wu 提交于
      In order to avoid double assignments of nested_attributes for `has_many`
      relations during record initialization, nested_attributes in `create_with`
      should not be passed into `klass.new` and have them populate during
      `initialize_internals_callback` with scope attributes.
      
      However, `create_with` keys should always have precedence over where
      clauses, so if there are same keys in both `create_with` and
      `where_values_hash`, the value in `create_with` should be the one that's
      used.
      5291044a
  12. 31 8月, 2018 1 次提交
  13. 31 7月, 2018 1 次提交
    • R
      Avoid extra scoping when using `Relation#update` · c83e30da
      Ryuta Kamizono 提交于
      Since 9ac7dd47, class level `update`, `destroy`, and `delete` were placed
      in the `Persistence` module as class methods.
      
      But `Relation#update` without passing ids which was introduced at #11898
      is not a class method, and it was caused the extra scoping regression
      #33470.
      
      I moved the relation method back into the `Relation` to fix the
      regression.
      
      Fixes #33470.
      c83e30da
  14. 19 4月, 2018 1 次提交
  15. 13 4月, 2018 1 次提交
  16. 15 2月, 2018 1 次提交
  17. 26 1月, 2018 4 次提交
  18. 25 1月, 2018 2 次提交
    • R
      Fix `count(:all)` with eager loading and having an order other than the driving table · ebc09ed9
      Ryuta Kamizono 提交于
      This is a regression caused by 6beb4de7.
      
      In PostgreSQL, ORDER BY expressions must appear in SELECT list when
      using DISTINCT.
      
      When using `count(:all)` with eager loading, Active Record enforces
      DISTINCT to count the driving table records only. 6beb4de7 was caused the
      regression because `count(:all)` with DISTINCT path no longer removes
      ORDER BY.
      
      We need to ignore ORDER BY when DISTINCT is enforced, otherwise not
      always generated valid SQL for PostgreSQL.
      
      Fixes #31783.
      ebc09ed9
    • D
      Avoid passing unnecessary arguments to relation · 6928950d
      Daniel Colson 提交于
      Most of the time the table and predicate_builder
      passed to Relation.new are exactly the
      arel_table and predicate builder of the
      given klass. This uses klass.arel_table
      and klass.predicate_builder as the defaults,
      so we don't have to pass them in most cases.
      
      This does change the signaure of both Relation and
      AssocationRelation. Are we ok with that?
      6928950d
  19. 20 12月, 2017 1 次提交
    • R
      Fix `count(:all)` to correctly work `distinct` with custom SELECT list · c6cd9a59
      Ryuta Kamizono 提交于
      Currently `count(:all)` with `distinct` doesn't work correctly because
      SELECT list is always replaced to `*` or primary key in that case even
      if having custom SELECT list.
      
      And also, PostgreSQL has a limitation that ORDER BY expressions must
      appear in select list for SELECT DISTINCT.
      
      Therefore, we should not replace custom SELECT list when using
      `count(:all)` with `distinct`.
      
      Closes #31277.
      c6cd9a59
  20. 19 12月, 2017 2 次提交
  21. 08 12月, 2017 1 次提交
    • R
      Fix `scope_for_create` to do not lose polymorphic associations · 6a8ce741
      Ryuta Kamizono 提交于
      This regression was caused at 213796fb due to polymorphic predicates are
      combined by `Arel::Nodes::And`. But I'd like to keep that combined
      because it would help inverting polymorphic predicates correctly
      (e9ba12f7), and we can collect equality nodes regardless of combined by
      `Arel::Nodes::And` (`a AND (b AND c) AND d` == `a AND b AND c AND d`).
      This change fixes the regression to collect equality nodes in
      `Arel::Nodes::And` as well.
      
      Fixes #31338.
      6a8ce741
  22. 10 11月, 2017 2 次提交
  23. 09 11月, 2017 7 次提交
  24. 09 10月, 2017 1 次提交
  25. 30 9月, 2017 1 次提交