1. 28 10月, 2015 2 次提交
  2. 27 10月, 2015 7 次提交
  3. 25 10月, 2015 2 次提交
  4. 24 10月, 2015 3 次提交
  5. 23 10月, 2015 1 次提交
  6. 22 10月, 2015 4 次提交
    • B
      Refactored association preloader for performance · 6ec7baad
      Bogdan Gusiev 提交于
      * less arrays created
      * less complexity with only one level of nesting in loop
      6ec7baad
    • R
      Refactor Calculations#execute_grouped_calculation and clean AR test case · 4f21d42f
      Rafael Sales 提交于
      * When tried to use `Company#accounts` test/models/company.rb I got:
      
      ```
      ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column:
      accounts.company_id: SELECT COUNT(*) AS count_all, "companies"."firm_id"
      AS companies_firm_id FROM "companies" INNER JOIN "accounts" ON
      "accounts"."company_id" = "companies"."id" GROUP BY "companies"."firm_id"
      ```
      
      * The refactor on Calculations class was just to simplify the code
      4f21d42f
    • R
      Fix generated projection fields in group by query · c2d33c4a
      Rafael Sales 提交于
      Closes #21922
      
      Let `Book(id, author_id)`, `Photo(id, book_id, author_id)` and `Author(id)`
      
      Running `Book.group(:author_id).joins(:photos).count` will produce:
      
      * Rails 4.2 - conflicts `author_id` in both projection and group by:
      ```sql
      SELECT COUNT(*) AS count_all, author_id AS author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY author_id
      ```
      
      * Master (9d02a25d) - conflicts `author_id` only in projection:
      ```sql
      SELECT COUNT(*) AS count_all, author_id AS author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY "books"."author_id"
      ```
      
      * With this fix:
      ```sql
      SELECT COUNT(*) AS count_all, "books"."author_id" AS books_author_id
        FROM "books" INNER JOIN "photos" ON "photos"."book_id" = "books"."id"
       GROUP BY "books"."author_id"
      ```
      c2d33c4a
    • R
      Remove `#tables` extra args again · edfb738b
      Ryuta Kamizono 提交于
      This issue was resolved by #21687 already. But re-add args by #18856.
      `#tables` extra args was only using by `#table_exists?`. This is for
      internal API. This commit will remove these extra args again.
      edfb738b
  7. 21 10月, 2015 14 次提交
    • J
      Extract native getter to attr_reader. · 6f47ea1a
      jbranchaud 提交于
      The getter is doing nothing more than returning the ivar, so it can be
      extracted to an attr_reader.
      6f47ea1a
    • Y
      move documentation of column options to `add_column`. Closes #20400. · 173fc1f7
      Yves Senn 提交于
      [ci skip]
      
      It's been a source of confusion that the lower-level `add_column`
      referenced the higher level `column` method for available options.
      `column` supports additional functionality like `index: true` that is
      not present on `add_column`.
      
      This patch moves common option documentation to `add_column` and only
      documents the additional options in `column`.
      173fc1f7
    • S
      typo · 172c0da0
      Scott Nelson 提交于
      172c0da0
    • J
      Update changelog with db rake task exit status fix · f33965f9
      Jay Hayes 提交于
      f33965f9
    • J
      Exit with non-zero status when db:drop fails · c2e597a7
      Jay Hayes 提交于
      * If the drop task fails for a reason other than the database not
        existing, processing should end. This is indicated by a non-zero
        exit status.
      * Since the backtrace is already printed to screen, we forgo
        printing it again by using an explicit call to `exit`.
      *  This modifies the behavior of the db:create task slightly in
        that the stack trace is no longer printed by default. If the `--trace`
        option is used, it will print the trace _after_ the error message.
      c2e597a7
    • J
      Exit with non-zero status when db:create fails · 2893e6c0
      Jay Hayes 提交于
      * If the create task fails for a reason other than the database already
        existing, processing should end. This is indicated by a non-zero exit
        status.
      * Since the backtrace is already printed to screen, we forgo printing it
        again by using an explicit call to `exit`.
      *  This modifies the behavior of the db:create task slightly in
        that the stack trace is no longer printed by default. If the `--trace`
        option is used, it will print the trace _after_ the error message.
      2893e6c0
    • J
      Fix test of drop failure · 1cd35be3
      Jay Hayes 提交于
      * Previously the sqlite3 adapter could not "fail" on drop. Now an error
        is raised when no file exists.
      * Also updates purge to be resilient of drop failures. This is how purge
        is expected to behave.
      1cd35be3
    • J
      fb42c492
    • S
      Fix test failures caused by d99db6b8 · 3e29d96e
      Sean Griffin 提交于
      I messed up the merge conflict, and accidentally removed a schema query
      that needed to be ignored.
      3e29d96e
    • S
      Qualify column names in calculation · a7628099
      Soutaro Matsumoto 提交于
      Column names inserted via `group` have to be qualified with table name.
      a7628099
    • S
      Don't add classes to the top level namespace · 0ceaa733
      Sean Griffin 提交于
      I've been writing too much Rust. My mind is still in the mode of things
      being auto-namespaced based on the file...
      0ceaa733
    • S
      Do not cache prepared statements that are unlikely to have cache hits · cbcdecd2
      Sean Griffin 提交于
      Prior to this commit, Rails makes no differentiation between whether a
      query uses bind parameters, and whether or not we cache that query as a
      prepared statement. This leads to the cache populating extremely fast in
      some cases, with the statements never being reused.
      
      In particular, the two problematic cases are `where(foo: [1, 2, 3])` and
      `where("foo = ?", 1)`. In both cases we'll end up quoting the values
      rather than using a bind param, causing a cache entry for every value
      ever used in that query.
      
      It was noted that we can probably eventually change `where("foo = ?",
      1)` to use a bind param, which would resolve that case. Additionally, on
      PG we can change our generated query to be `WHERE foo = ANY($1)`, and
      pass an array for the bind param. I hope to accomplish both in the
      future.
      
      For SQLite and MySQL, we still end up preparing the statements anyway,
      we just don't cache it. The statement will be cleaned up after it is
      executed. On postgres, we skip the prepare step entirely, as an API is
      provided to execute with bind params without preparing the statement.
      
      I'm not 100% happy on the way this ended up being structured. I was
      hoping to use a decorator on the visitor, rather than mixing a module
      into the object, but the way Arel has it's visitor pattern set up makes
      it very difficult to extend without inheritance. I'd like to remove the
      duplication from the various places that are extending it, but that'll
      require a larger restructuring of that initialization logic. I'm going
      to take another look at the structure of it soon.
      
      This changes the signature of one of the adapter's internals, and will
      require downstream changes from third party adapters. I'm not too
      worried about this, as worst case they can simply add the parameter and
      always ignore it, and just keep their previous behavior.
      
      Fixes #21992.
      cbcdecd2
    • R
      209f3b30
    • K
  8. 20 10月, 2015 1 次提交
  9. 19 10月, 2015 1 次提交
    • J
      Reorder application of has_many association constraints. · d9bb13ba
      jbranchaud 提交于
      With `unscope!` called last, it undoes `where` constraints of the same
      value when the `where` is chained after the `unscope`. This is what a
      `rewhere` does. This is undesirable behavior.
      
      The included tests demonstrate both the `unscope(...).where(...)`
      behavior as well as the direct use of `rewhere(...)`.
      
      This is in reference to #21955.
      d9bb13ba
  10. 18 10月, 2015 2 次提交
  11. 17 10月, 2015 2 次提交
  12. 16 10月, 2015 1 次提交