1. 22 10月, 2015 1 次提交
    • 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
  2. 21 10月, 2015 7 次提交
    • 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
    • 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
    • K
  3. 20 10月, 2015 1 次提交
  4. 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
  5. 18 10月, 2015 2 次提交
  6. 17 10月, 2015 1 次提交
  7. 16 10月, 2015 3 次提交
    • J
      `where` raises ArgumentError on unsupported types. · 7663376f
      Jake Worth 提交于
      [#20473]
      7663376f
    • M
      fixes #21815 · 86d2924a
      Maarten Jacobs 提交于
      The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM.
      
      This commit adds:
      
      A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because
      - model couldn't be defined inline
      - transactional testing needed to be turned off to get it to pass the MySQL tests
      This seemed cleaner than putting it in an existing testcase file.
      
      It adds :usec as a dateformat that calculates datetime in microseconds
      
      It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
      86d2924a
    • I
      [ci skip] readonly options has been removed · 15f75193
      Ignatius Reza 提交于
      15f75193
  8. 15 10月, 2015 5 次提交
    • T
      Add deprecation warning to `ActiveRecord::Relation#update` · b901a494
      Ted Johansson 提交于
      When passing an instance of `ActiveRecord::Base` to `#update`, it would
      internally call `#find`, resulting in a misleading deprecation warning.
      
      This change gives this deprecated use of `#update` its own, meaningful
      warning.
      b901a494
    • R
      Add stored procedure test in mysql2 · d39b6f77
      Ryuta Kamizono 提交于
      d39b6f77
    • A
      freeze the column name to drop string allocations in dirty checks · b6cf69eb
      Aaron Patterson 提交于
      Dirty checking keeps a hash where the keys are the column name and the
      value is a dup of the value from the database[1].  This hash is kept for
      every AR object, which means that we dup every column name for every AR
      object that does dirty checking.  Freezing the column name prevents the
      column name from being duped and reduced overall string allocations.
      
      Here is a benchmark to demonstrate:
      
      ```ruby
      require 'active_record'
      
      class Topic < ActiveRecord::Base
      end
      
      20.times do |i|
        Process.waitpid fork {
          ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
      
          ActiveRecord::Base.connection.instance_eval do
            create_table(:topics) do |t|
              t.string   :title, limit: 250
              t.string   :author_name
              t.string   :author_email_address
              t.string   :parent_title
              t.string   :type
              t.string   :group
              i.times do |j|
                t.string :"aaa#{j}"
              end
              t.timestamps null: true
            end
          end
      
          ObjectSpace::AllocationTracer.setup(%i{type})
      
          Topic.create title: "aaron" # heat cache
      
          result = ObjectSpace::AllocationTracer.trace do
            10.times do |i|
              Topic.create title: "aaron #{i}"
            end
          end
      
          puts "#{Topic.columns.length},#{(result.find { |k,v| k.first == :T_STRING }.last.first / 10)}"
        }
      end
      ```
      
      1. https://github.com/rails/rails/blob/3ad381c3f8598d9920998c8949a96b5f62b280dd/activerecord/lib/active_record/attribute_set/builder.rb#L102
      b6cf69eb
    • R
      Make `AbstractMysqlAdapter#version` public · d9e74ace
      Ryuta Kamizono 提交于
      d9e74ace
    • R
      Fix to correctly schema dump the `tinyblob` · f8438ae3
      Ryuta Kamizono 提交于
      Currently `tinyblob` is dumped to `t.binary "tiny_blob", limit: 255`.
      But `t.binary ... limit: 255` is generating SQL to `varchar(255)`.
      It is incorrect. This commit fixes this problem.
      f8438ae3
  9. 14 10月, 2015 7 次提交
  10. 13 10月, 2015 11 次提交
  11. 11 10月, 2015 1 次提交