1. 08 8月, 2019 1 次提交
  2. 01 8月, 2019 1 次提交
  3. 26 6月, 2019 1 次提交
  4. 17 6月, 2019 1 次提交
    • R
      PostgreSQL: Fix GROUP BY with ORDER BY virtual count attribute · cb0299c9
      Ryuta Kamizono 提交于
      GROUP BY with virtual count attribute is invalid for almost all
      databases, but it is valid for PostgreSQL, and it had worked until Rails
      5.2.2, so it is a regression for Rails 5.2.3 (caused by 311f0011).
      
      I can't find perfectly solution for fixing this for now, but I would not
      like to break existing apps, so I decided to allow referencing virtual
      count attribute in ORDER BY clause when GROUP BY aggrigation (it partly
      revert the effect of 311f0011) to fix the regression #36022.
      
      Fixes #36022.
      cb0299c9
  5. 10 6月, 2019 1 次提交
    • R
      Allow column name with function (e.g. `length(title)`) as safe SQL string · 64d8c54e
      Ryuta Kamizono 提交于
      Currently, almost all "Dangerous query method" warnings are false alarm.
      As long as almost all the warnings are false alarm, developers think
      "Let's ignore the warnings by using `Arel.sql()`, it actually is false
      alarm in practice.", so I think we should effort to reduce false alarm
      in order to make the warnings valuable.
      
      This allows column name with function (e.g. `length(title)`) as safe SQL
      string, which is very common false alarm pattern, even in the our
      codebase.
      
      Related 6c82b6c9, 6607ecb2, #36420.
      
      Fixes #32995.
      64d8c54e
  6. 07 6月, 2019 1 次提交
  7. 06 6月, 2019 1 次提交
    • R
      Allow quoted identifier string as safe SQL string · 7696f44f
      Ryuta Kamizono 提交于
      Currently `posts.title` is regarded as a safe SQL string, but
      `"posts"."title"` (it is a result of `quote_table_name("posts.title")`)
      is regarded as an unsafe SQL string even though a result of
      `quote_table_name` should obviously be regarded as a safe SQL string,
      since the column name matcher doesn't respect quotation, it is a little
      annoying.
      
      This changes the column name matcher to allow quoted identifiers as safe
      SQL string, now all results of the `quote_table_name` are regarded as
      safe SQL string.
      7696f44f
  8. 22 5月, 2019 1 次提交
  9. 04 4月, 2019 1 次提交
    • R
      Fix `count(:all)` with eager loading and explicit select and order · 060e09df
      Ryuta Kamizono 提交于
      This follows up ebc09ed9.
      
      We've still experienced a regression for `size` (`count(:all)`) with
      eager loading and explicit select and order when upgrading Rails to 5.1.
      
      In that case, the eager loading enforces `distinct` to subselect but
      still keep the custom select, it would cause the ORDER BY with DISTINCT
      issue.
      
      ```
      % ARCONN=postgresql bundle exec ruby -w -Itest test/cases/relations_test.rb -n test_size_with_eager_loading_and_custom_select_and_order
      Using postgresql
      Run options: -n test_size_with_eager_loading_and_custom_select_and_order --seed 8356
      
      # Running:
      
      E
      
      Error:
      RelationTest#test_size_with_eager_loading_and_custom_select_and_order:
      ActiveRecord::StatementInvalid: PG::InvalidColumnReference: ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
      LINE 1: ..." ON "comments"."post_id" = "posts"."id" ORDER BY comments.i...
                                                                   ^
      ```
      
      As another problem on `distinct` is enforced, the result of `count`
      becomes fewer than expected if `select` is given explicitly.
      
      e.g.
      
      ```ruby
      Post.select(:type).count
      # => 11
      
      Post.select(:type).distinct.count
      # => 3
      ```
      
      As long as `distinct` is enforced, we need to care to keep the result of
      `count`.
      
      This fixes both the `count` with eager loading problems.
      060e09df
  10. 30 3月, 2019 1 次提交
  11. 07 3月, 2019 1 次提交
  12. 01 3月, 2019 1 次提交
  13. 27 2月, 2019 1 次提交
  14. 26 2月, 2019 1 次提交
  15. 24 2月, 2019 2 次提交
  16. 23 2月, 2019 2 次提交
  17. 22 2月, 2019 3 次提交
  18. 19 2月, 2019 1 次提交
  19. 17 2月, 2019 2 次提交
  20. 15 2月, 2019 2 次提交
  21. 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
  22. 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
  23. 06 2月, 2019 1 次提交
  24. 08 12月, 2018 1 次提交
  25. 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
  26. 16 9月, 2018 1 次提交
  27. 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
  28. 31 8月, 2018 1 次提交
  29. 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
  30. 19 4月, 2018 1 次提交
  31. 13 4月, 2018 1 次提交
  32. 15 2月, 2018 1 次提交
  33. 26 1月, 2018 2 次提交