1. 18 2月, 2016 2 次提交
  2. 17 2月, 2016 1 次提交
    • P
      Fixed `where` for polymorphic associations when passed an array containing different types. · 359adaed
      Philippe Huibonhoa 提交于
      When passing in an array of different types of objects to `where`, it would only take into account the class of the first object in the array.
      
          PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
      	# => SELECT "price_estimates".* FROM "price_estimates"
               WHERE ("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" IN (1, 2))
      
      This is fixed to properly look for any records matching both type and id:
      
          PriceEstimate.where(estimate_of: [Treasure.find(1), Car.find(2)])
          # => SELECT "price_estimates".* FROM "price_estimates"
               WHERE (("price_estimates"."estimate_of_type" = 'Treasure' AND "price_estimates"."estimate_of_id" = 1)
               OR ("price_estimates"."estimate_of_type" = 'Car' AND "price_estimates"."estimate_of_id" = 2))
      359adaed
  3. 16 2月, 2016 2 次提交
    • V
      Add missing CHANGELOG for regression fix in #18155 which fixes #13387 · 8d3912ac
      Vipul A M 提交于
      [ci skip]
      8d3912ac
    • G
      Let t.foreign_key use the same `to_table` twice · aedde2a3
      George Millo 提交于
      Previously if you used `t.foreign_key` twice within the same
      `create_table` block using the same `to_table`, all statements except
      the final one would fail silently. For example, the following code:
      
          def change
            create_table :flights do |t|
              t.integer :from_id, index: true, null: false
              t.integer :to_id,   index: true, null: false
      
              t.foreign_key :airports, column: :from_id
              t.foreign_key :airports, column: :to_id
            end
          end
      
      Would only create one foreign key, on the column `from_id`.
      
      This commit allows multiple foreign keys to the same table to be created
      within one `create_table` block.
      aedde2a3
  4. 13 2月, 2016 3 次提交
  5. 11 2月, 2016 1 次提交
  6. 07 2月, 2016 1 次提交
    • M
      Added numeric helper into migrations. · aa38f7d6
      Mehmet Emin İNAÇ 提交于
      With this addition, you can add a column into the table like:
      
      ```
        create_table(:numeric_types) do |t|
          t.numeric :foo, precision: 10, scale: 2, default: 2.0
        end
      ```
      
      The result of the migration above is same with:
      
      ```
        create_table(:numeric_types) do |t|
          t.decimal :foo, precision: 10, scale: 2, default: 2.0
        end
      ```
      aa38f7d6
  7. 06 2月, 2016 1 次提交
    • S
      Revert "Dump indexes in `create_table` instead of `add_index`" · d666a5a5
      Sean Griffin 提交于
      This reverts commit 99801c6a.
      
      Ultimately it doesn't matter whether `add_index` or `t.index` are used
      in the schema dumper in any meaningful way. There are gems out there
      which hook into the old behavior for things like indexing materialized
      views. Since the reverted commit doesn't seem to add much benefit,
      there's no reason for us to break these gems.
      d666a5a5
  8. 03 2月, 2016 1 次提交
  9. 02 2月, 2016 3 次提交
  10. 31 1月, 2016 1 次提交
  11. 28 1月, 2016 1 次提交
  12. 27 1月, 2016 2 次提交
  13. 24 1月, 2016 1 次提交
    • P
      Pare back default `index` option for the migration generator · 909818b9
      Prathamesh Sonpatki 提交于
      - Using `references` or `belongs_to` in migrations will always add index
        for the referenced column by default, without adding `index:true` option
        to generated migration file.
      - Users can opt out of this by passing `index: false`.
      - Legacy migrations won't be affected by this change. They will continue
        to run as they were before.
      - Fixes #18146
      909818b9
  14. 20 1月, 2016 2 次提交
  15. 18 1月, 2016 1 次提交
  16. 15 1月, 2016 1 次提交
  17. 13 1月, 2016 3 次提交
  18. 12 1月, 2016 1 次提交
  19. 10 1月, 2016 1 次提交
  20. 09 1月, 2016 1 次提交
  21. 06 1月, 2016 1 次提交
  22. 05 1月, 2016 1 次提交
    • R
      Add short-hand methods for text and blob types in MySQL · 4d4239f9
      Ryuta Kamizono 提交于
      In Pg and Sqlite3, `:text` and `:binary` have variable unlimited length.
      But in MySQL, these have limited length for each types (ref #21591, #21619).
      This change adds short-hand methods for each text and blob types.
      
      Example:
      
          create_table :foos do |t|
            t.tinyblob   :tiny_blob
            t.mediumblob :medium_blob
            t.longblob   :long_blob
            t.tinytext   :tiny_text
            t.mediumtext :medium_text
            t.longtext   :long_text
          end
      4d4239f9
  23. 25 12月, 2015 2 次提交
    • B
      Fix `first(limit)` to take advantage of `loaded?` records if available · b42c3255
      Ben Woosley 提交于
      I realized that `first(2)`, etc. was unnecessarily querying for the
      records when they were already preloaded. This was because
      `find_nth_with_limit` can not know which `@records` to return because
      it conflates the `offset` and `index` into a single variable, while
      the `@records` only needs the `index` itself to select the proper
      record.
      
      Because `find_nth` and `find_nth_with_limit` are public methods, I
      instead introduced a private method `find_nth_with_limit_and_offset`
      which is called internally and handles the `loaded?` checking.
      
      Once the `offset` argument is removed from `find_nth`,
      `find_nth_with_limit_and_offset` can be collapsed into
      `find_nth_with_limit`, with `offset` always equal to `offset_index`.
      b42c3255
    • B
      Deprecate passing `offset` to `find_nth` · 16a476e4
      Ben Woosley 提交于
      All uses of the `offset` are passing `offset_index`. Better to push
      down the `offset` consideration into `find_nth`.
      
      This also works toward enabling `find_nth_with_limit` to take
      advantage of the `loaded?` state of the relation.
      16a476e4
  24. 23 12月, 2015 1 次提交
  25. 21 12月, 2015 2 次提交
    • Y
      Revert "Merge pull request #22486 from methyl/fix-includes-for-groupped-association" · b06f6a1d
      Yves Senn 提交于
      This reverts commit 537ac7d6, reversing
      changes made to 9c9c54ab.
      
      Reason:
      The way we preload associations will change the meaning of GROUP BY
      operations. This is illustrated in the SQL generated by the added
      test (failing on PG):
      
      Association Load:
      D, [2015-12-21T12:26:07.169920 #26969] DEBUG -- :   Post Load (0.7ms)  SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" = $1 GROUP BY posts.id ORDER BY SUM(comments.tags_count)  [["author_id", 1]]
      
      Preload:
      D, [2015-12-21T12:26:07.128305 #26969] DEBUG -- :   Post Load (1.3ms)  SELECT "posts".* FROM "posts" LEFT JOIN comments ON comments.post_id = posts.id WHERE "posts"."author_id" IN (1, 2, 3) GROUP BY posts.id ORDER BY SUM(comments.tags_count)
      b06f6a1d
    • G
      No more no changes entries in the CHANGELOGs · c5b6ec7b
      Genadi Samokovarov 提交于
      During the `5.0.0.beta1` release, the CHANGELOGs got an entry like the
      following:
      
      ```
      * No changes.
      ```
      
      It is kinda confusing as there are indeed changes after it. Not a
      biggie, just a small pass over the CHANGELOGs.
      
      [ci skip]
      c5b6ec7b
  26. 19 12月, 2015 2 次提交
  27. 17 12月, 2015 1 次提交