1. 02 11月, 2015 2 次提交
  2. 31 10月, 2015 1 次提交
  3. 30 10月, 2015 5 次提交
  4. 29 10月, 2015 1 次提交
  5. 27 10月, 2015 1 次提交
  6. 24 10月, 2015 1 次提交
  7. 22 10月, 2015 1 次提交
    • 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
  8. 21 10月, 2015 5 次提交
    • J
      Update changelog with db rake task exit status fix · f33965f9
      Jay Hayes 提交于
      f33965f9
    • J
      fb42c492
    • S
      Qualify column names in calculation · a7628099
      Soutaro Matsumoto 提交于
      Column names inserted via `group` have to be qualified with table name.
      a7628099
    • 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
  9. 16 10月, 2015 2 次提交
    • J
      `where` raises ArgumentError on unsupported types. · 7663376f
      Jake Worth 提交于
      [#20473]
      7663376f
    • S
      Add an immutable string type to opt out of string duping · 34321e4a
      Sean Griffin 提交于
      This type adds an escape hatch to apps for which string duping causes
      unacceptable memory growth. The reason we are duping them is in order to
      detect mutation, which was a feature added to 4.2 in #15674. The string
      type was modified to support this behavior in #15788.
      
      Memory growth is really only a concern for string types, as it's the
      only mutable type where the act of coersion does not create a new object
      regardless (as we're usually returning an object of a different class).
      
      I do feel strongly that if we are going to support detecting mutation,
      we should do it universally for any type which is mutable. While it is
      less common and ideomatic to mutate strings than arrays or hashes, there
      shouldn't be rules or gotchas to understanding our behavior.
      
      However, I also appreciate that for apps which are using a lot of string
      columns, this would increase the number of allocations by a large
      factor. To ensure that we keep our contract, if you'd like to opt out of
      mutation detection on strings, you'll also be option out of mutation of
      those strings.
      
      I'm not completely married to the thought that strings coming out of
      this actually need to be frozen -- and I think the name is correct
      either way, as the purpose of this is to provide a string type which
      does not detect mutation.
      
      In the new implementation, I'm only overriding `cast_value`. I did not
      port over the duping in `serialize`. I cannot think of a reason we'd
      need to dup the string there, and the tests pass without it.
      Unfortunately that line was introduced at a time where I was not nearly
      as good about writing my commit messages, so I have no context as to
      why I added it. Thanks past Sean. You are a jerk.
      34321e4a
  10. 15 10月, 2015 1 次提交
  11. 13 10月, 2015 1 次提交
    • Y
      `:to_table` when adding a fk through `add_reference`. · 5a14349b
      Yves Senn 提交于
      Closes #21563.
      
      The `name` argument of `add_references` was both used to generate the
      column name `<name>_id` and as the target table for the foreign key
      `name.pluralize`.
      
      It's primary purpose is to define the column name. In cases where the
      `to_table` of the foreign key is different than the column name we
      should be able to specify it individually.
      5a14349b
  12. 09 10月, 2015 1 次提交
    • M
      Avoid leaking the first relation we call #first on · 1b6fcae9
      Matthew Draper 提交于
      With the previous implementation, the block passed to
      define_singleton_method, which will live forever as the method body,
      captures the parameters (args and block) in its enclosure.
      
      For the current_scope registry, that can include an AR::Relation.
      1b6fcae9
  13. 08 10月, 2015 1 次提交
  14. 06 10月, 2015 1 次提交
  15. 05 10月, 2015 1 次提交
  16. 02 10月, 2015 1 次提交
  17. 25 9月, 2015 1 次提交
    • S
      `validates_acceptance_of` shouldn't require a database connection · 37661bfc
      Sean Griffin 提交于
      The implementation of `attribute_method?` on Active Record requires
      establishing a database connection and querying the schema. As a general
      rule, we don't want to require database connections for any class macro,
      as the class should be able to be loaded without a database (e.g. for
      things like compiling assets).
      
      Instead of eagerly defining these methods, we do it lazily the first
      time they are accessed via `method_missing`. This should not cause any
      performance hits, as it will only hit `method_missing` once for the
      entire class.
      37661bfc
  18. 24 9月, 2015 1 次提交
  19. 23 9月, 2015 2 次提交
    • B
      Fixed taking precision into count when assigning a value to timestamp attribute · d03f5196
      Bogdan Gusiev 提交于
      Timestamp column can have less precision than ruby timestamp
      In result in how big a fraction of a second can be stored in the
      database.
      
        m = Model.create!
        m.created_at.usec == m.reload.created_at.usec
          # => false
          # due to different seconds precision in Time.now and database column
      
      If the precision is low enough, (mysql default is 0, so it is always low
      enough by default) the value changes when model is reloaded from the
      database. This patch fixes that issue ensuring that any timestamp
      assigned as an attribute is converted to column precision under the
      attribute.
      d03f5196
    • Y
      introduce `conn.data_source_exists?` and `conn.data_sources`. · 152b85f0
      Yves Senn 提交于
      These new methods are used from the Active Record model layer to
      determine which relations are viable to back a model. These new methods
      allow us to change `conn.tables` in the future to only return tables and
      no views. Same for `conn.table_exists?`.
      
      The goal is to provide the following introspection methods on the
      connection:
      
      * `tables`
      * `table_exists?`
      * `views`
      * `view_exists?`
      * `data_sources` (views + tables)
      * `data_source_exists?` (views + tables)
      152b85f0
  20. 22 9月, 2015 1 次提交
  21. 20 9月, 2015 1 次提交
  22. 18 9月, 2015 2 次提交
    • R
      Add `unsigned` types for numeric data types in MySQL · dfeb3ee7
      Ryuta Kamizono 提交于
      In the case of using `unsigned` as the type:
      
          create_table :foos do |t|
            t.unsigned_integer :unsigned_integer
            t.unsigned_bigint  :unsigned_bigint
            t.unsigned_float   :unsigned_float
            t.unsigned_decimal :unsigned_decimal, precision: 10, scale: 2
          end
      dfeb3ee7
    • R
      Add `unsigned` support for numeric data types in MySQL · f3772f72
      Ryuta Kamizono 提交于
      Example:
      
          create_table :foos do |t|
            t.integer :unsigned_integer, unsigned: true
            t.bigint  :unsigned_bigint,  unsigned: true
            t.float   :unsigned_float,   unsigned: true
            t.decimal :unsigned_decimal, unsigned: true, precision: 10, scale: 2
          end
      f3772f72
  23. 13 9月, 2015 1 次提交
  24. 12 9月, 2015 1 次提交
    • R
      Allow fixtures YAML files to set the model class in the file itself · 2acec465
      Roque Pinel 提交于
      Currently, `set_fixture_class` is only available using the
      `TestFixtures` concern and it is ignored for `rake db:fixtures:load`.
      Using the correct model class, it is possible for the fixture load
      to also load the associations from the YAML files (e.g., `:belongs_to`
      and `:has_many`).
      2acec465
  25. 08 9月, 2015 1 次提交
  26. 07 9月, 2015 2 次提交
  27. 06 9月, 2015 1 次提交