1. 08 9月, 2015 23 次提交
    • Y
      Merge pull request #21530 from arvindmehra/am-ar-to-activerecord · 3e617bbf
      Yves Senn 提交于
      Replace AR with ActiveRecord to make it more readable [ci skip]
      3e617bbf
    • Y
      Merge pull request #21528 from yui-knk/test/add_tests_for_mysql2_view · 8a639ffc
      Yves Senn 提交于
      Add tests for test/cases/adapters/mysql2/view_test.rb
      8a639ffc
    • Y
      Add view tests for MySQL · bb0d7078
      yui-knk 提交于
      Basically view tests for MySQL are same with
      `test/cases/adapters/postgresql/view_test.rb`.
      
      So move `test/cases/adapters/postgresql/view_test.rb` to
      `test/cases/view_test.rb` and make them only run if
      `current_adapter` supports writable view.
      bb0d7078
    • A
      dad0c267
    • K
      Merge pull request #21519 from y-yagi/test_runner_raise_error · e75b92c0
      Kasper Timm Hansen 提交于
      raise LoadError when a non-existent file or directory is specified to the test runner
      e75b92c0
    • R
      💣 · b4f82efd
      Rafael Mendonça França 提交于
      b4f82efd
    • R
      Memoized reflections accessor · 0675210c
      Rafael Mendonça França 提交于
      Its value never change since associations are defined at class load time
      so there is no need to build the hash everytime the method is called.
      
      Before this change:
      
          Calculating -------------------------------------
                   reflections   804.000  i/100ms
          -------------------------------------------------
                   reflections      8.213k (±26.2%) i/s -     36.180k
      
      After this change:
      
          Calculating -------------------------------------
                   reflections    24.548k i/100ms
          -------------------------------------------------
                   reflections      1.591M (±25.7%) i/s -      7.364M
      
      Benchmark script:
      
          require 'bundler/setup'
      
          require 'active_record'
          require 'benchmark/ips'
      
          ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
          ActiveRecord::Migration.verbose = false
      
          ActiveRecord::Schema.define do
            100.times do |i|
              create_table "users#{i}", force: true
            end
      
            create_table :cars, force: true do |t|
              100.times do |i|
                t.references "users#{i}"
              end
            end
          end
      
          class Car < ActiveRecord::Base
            100.times do |i|
              belongs_to "users#{i}".to_sym
            end
          end
      
          Benchmark.ips do |x|
            x.report('reflections') { Car.reflections }
          end
      0675210c
    • R
      Merge pull request #21537 from tgxworld/perf_reduce_allocation · 9bf772d9
      Rafael Mendonça França 提交于
      PERF: Reduce allocation in `resolve_column_aliases`.
      9bf772d9
    • G
      Reduce allocation in `resolve_column_aliases`. · 607a4482
      Guo Xiang Tan 提交于
      Benchmark Script Used:
      ```
      begin
        require 'bundler/inline'
      rescue LoadError => e
        $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
        raise e
      end
      
      gemfile(true) do
        source 'https://rubygems.org'
        gem 'rails', path: '~/rails' # master against ref "f1f0a3f8"
        gem 'arel', github: 'rails/arel', branch: 'master'
        gem 'rack', github: 'rack/rack', branch: 'master'
        gem 'sass'
        gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
        gem 'sprockets', github: 'rails/sprockets', branch: 'master'
        gem 'pg'
        gem 'benchmark-ips'
      end
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection('postgres://postgres@localhost:5432/rubybench')
      
      ActiveRecord::Migration.verbose = false
      
      ActiveRecord::Schema.define do
        create_table :users, force: true do |t|
          t.string :name, :email
          t.timestamps null: false
        end
      end
      
      class User < ActiveRecord::Base; end
      
      attributes = {
        name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        email: "foobar@email.com",
      }
      
      1000.times { User.create!(attributes) }
      
      Benchmark.ips(5, 3) do |x|
        x.report('where with hash single') { User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.report('where with string single') { User.where("users.name = ?", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.report('where with hash double') { User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", email: "foobar@email.com") }
        x.report('where with string double') { User.where("users.name = ? AND users.email = ?", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", "foobar@email.com") }
        x.compare!
      end
      ```
      
      Before:
      ```
      Calculating -------------------------------------
      where with hash single
                               3.300k i/100ms
      where with string single
                               4.965k i/100ms
      where with hash double
                               2.594k i/100ms
      where with string double
                               4.400k i/100ms
      -------------------------------------------------
      where with hash single
                               35.161k (± 1.2%) i/s -    178.200k
      where with string single
                               53.368k (± 2.9%) i/s -    268.110k
      where with hash double
                               27.364k (± 1.1%) i/s -    137.482k
      where with string double
                               46.876k (± 2.1%) i/s -    237.600k
      
      Comparison:
      where with string single:    53368.1 i/s
      where with string double:    46875.5 i/s - 1.14x slower
      where with hash single:    35160.8 i/s - 1.52x slower
      where with hash double:    27364.0 i/s - 1.95x slower
      ```
      
      After:
      ```
      Calculating -------------------------------------
      where with hash single
                               3.403k i/100ms
      where with string single
                               5.167k i/100ms
      where with hash double
                               2.659k i/100ms
      where with string double
                               4.597k i/100ms
      -------------------------------------------------
      where with hash single
                               36.410k (± 1.3%) i/s -    183.762k
      where with string single
                               55.009k (± 2.6%) i/s -    279.018k
      where with hash double
                               27.951k (± 1.4%) i/s -    140.927k
      where with string double
                               48.362k (± 2.6%) i/s -    243.641k
      
      Comparison:
      where with string single:    55008.6 i/s
      where with string double:    48361.5 i/s - 1.14x slower
      where with hash single:    36410.1 i/s - 1.51x slower
      where with hash double:    27950.9 i/s - 1.97x slower
      ```
      607a4482
    • J
      Merge pull request #21520 from jeremy/friendlier-force-ssl · a11571ce
      Jeremy Daer (Kemper) 提交于
      Make `config.force_ssl` less dangerous to try and easier to disable
      a11571ce
    • J
      Make `config.force_ssl` less dangerous to try and easier to disable · f6749224
      Jeremy Daer 提交于
      SSL redirect:
      * Move `:host` and `:port` options within `redirect: { … }`. Deprecate.
      * Introduce `:status` and `:body` to customize the redirect response.
        The 301 permanent default makes it difficult to test the redirect and
        back out of it since browsers remember the 301. Test with a 302 or 307
        instead, then switch to 301 once you're confident that all is well.
      
      HTTP Strict Transport Security (HSTS):
      * Shorter max-age. Shorten the default max-age from 1 year to 180 days,
        the low end for https://www.ssllabs.com/ssltest/ grading and greater
        than the 18-week minimum to qualify for browser preload lists.
      * Disabling HSTS. Setting `hsts: false` now sets `hsts: { expires: 0 }`
        instead of omitting the header. Omitting does nothing to disable HSTS
        since browsers hang on to your previous settings until they expire.
        Sending `{ hsts: { expires: 0 }}` flushes out old browser settings and
        actually disables HSTS:
          http://tools.ietf.org/html/rfc6797#section-6.1.1
      * HSTS Preload. Introduce `preload: true` to set the `preload` flag,
        indicating that your site may be included in browser preload lists,
        including Chrome, Firefox, Safari, IE11, and Edge. Submit your site:
          https://hstspreload.appspot.com
      f6749224
    • J
      Merge pull request #21536 from jeremy/support-mysql2-0.4.0 · 81dd3872
      Jeremy Daer (Kemper) 提交于
      Support mysql2 0.4.0, first release with prepared statements support
      81dd3872
    • J
      Support mysql2 0.4.0, first release with prepared statements support · 5da5e377
      Jeremy Daer 提交于
      Known failure on Ruby 2.3/trunk: brianmario/mysql2#671
      5da5e377
    • J
      .gitignore: Ignore .ruby-version in any subdir · cad75ecf
      Jeremy Daer 提交于
      cad75ecf
    • Y
      modify to pass the correct argument to the test runner from rake · df744b56
      yuuji.yaginuma 提交于
      test runner sets file to be tested in plugin_rails_options,
      but in plugin_rails_options, processing has been made to the argument of the
      actual command rather than the argument of Minitest.run.
      
      For example, if you run `./bin rake db:migrate test`, the options[:patterns], `db:migrate test` was incorrectly set.
      df744b56
    • R
      Use Hash[] instead of Hash#dup in resolve_column_aliases · d1ce45cd
      Rafael Mendonça França 提交于
      Related with #20418
      d1ce45cd
    • R
      Merge pull request #21534 from Vratislav/clarify-custom-config-guide · 8167d18c
      Rafael Mendonça França 提交于
      [Rails Guides] Clarify custom code configuration [ci skip]
      8167d18c
    • R
      Revert "Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once" · 7b9b0b53
      Rafael Mendonça França 提交于
      This reverts commit 51dd2588, reversing
      changes made to ecb4e4b2.
      
      This broke Active Record tests
      7b9b0b53
    • R
      Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once · 51dd2588
      Rafael Mendonça França 提交于
      Validate multiple contexts on `valid?` and `invalid?` at once
      51dd2588
    • R
      Merge pull request #21522 from tgxworld/scope_perf · ecb4e4b2
      Rafael Mendonça França 提交于
      PERF: Scope performance.
      ecb4e4b2
    • M
      Correct query for PostgreSQL 8.2 · 8c34d106
      Matthew Draper 提交于
      Generic cast-to-text was only added in 8.3.
      8c34d106
    • R
      Merge pull request #21523 from tgxworld/improve_perf_all · 64a1cb1a
      Rafael Mendonça França 提交于
      PERF: Don't create a Relation when it is not needed.
      64a1cb1a
    • A
      Merge pull request #21531 from amitsuroliya/typo_fix1 · 2cc6f6b7
      Arun Agrawal 提交于
      Typo fix (ci skip)
      2cc6f6b7
  2. 07 9月, 2015 15 次提交
    • A
      Typo fix [ci skip] · 1678bf24
      amitkumarsuroliya 提交于
      `lengh` should be `length`  
      1678bf24
    • Y
      Merge pull request #20534 from qnm/activesupport-require-issue · 92d17007
      Yves Senn 提交于
      Add require to ensure Time#advance works without implicit required
      92d17007
    • Y
      Merge pull request #21527 from rngtng/fix-migrator-path-setup · 8e155b0a
      Yves Senn 提交于
      Use global migrations_path configuration in Migrator
      8e155b0a
    • T
    • Y
      changelog, minor formatting changes. · 488afd5c
      Yves Senn 提交于
      488afd5c
    • A
      Merge pull request #21524 from gfx/do_not_localize_for_to_sentence · 3f2267eb
      Akira Matsuda 提交于
      Fix strange messages for `rails g foo`
      3f2267eb
    • F
      Fix strange messages for `rails g foo` · 3215c6b7
      FUJI Goro (gfx) 提交于
      3215c6b7
    • G
      PERF: Don't create a Relation when it is not needed. · 69de09c5
      Guo Xiang Tan 提交于
      Benchmark script used:
      ```
      begin
        require 'bundler/inline'
      rescue LoadError => e
        $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
        raise e
      end
      
      gemfile(true) do
        source 'https://rubygems.org'
        gem 'rails', path: '~/rails' # master against ref "f1f0a3f8"
        gem 'arel', github: 'rails/arel', branch: 'master'
        gem 'rack', github: 'rack/rack', branch: 'master'
        gem 'sass'
        gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
        gem 'sprockets', github: 'rails/sprockets', branch: 'master'
        gem 'pg'
        gem 'benchmark-ips'
      end
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection('postgres://postgres@localhost:5432/rubybench')
      
      ActiveRecord::Migration.verbose = false
      
      ActiveRecord::Schema.define do
        create_table :users, force: true do |t|
          t.string :name, :email
          t.timestamps null: false
        end
      end
      
      class User < ActiveRecord::Base; end
      
      attributes = {
        name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        email: "foobar@email.com",
      }
      
      1000.times { User.create!(attributes) }
      
      Benchmark.ips(5, 3) do |x|
        x.report('all') { User.all }
      end
      
      key =
        if RUBY_VERSION < '2.2'
          :total_allocated_object
        else
          :total_allocated_objects
        end
      
      before = GC.stat[key]
      User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
      after = GC.stat[key]
      puts "Total Allocated Object: #{after - before}"
      
      ```
      
      Before:
      ```
      Calculating -------------------------------------
                       all    17.569k i/100ms
      -------------------------------------------------
                       all    190.854k (± 3.3%) i/s -    966.295k
      Total Allocated Object: 85
      ```
      
      After:
      ```
      Calculating -------------------------------------
                       all    22.237k i/100ms
      -------------------------------------------------
                       all    262.715k (± 5.5%) i/s -      1.312M
      Total Allocated Object: 80
      ```
      69de09c5
    • Y
      Merge pull request #21250 from ronakjangir47/safe_const · 2aad0b41
      Yves Senn 提交于
      safe_constantize - Added Object scoped missing test cases
      2aad0b41
    • K
      Merge pull request #21480 from amitsuroliya/add_return_value_description · b5a489fc
      Kasper Timm Hansen 提交于
      adding description of return value [ci skip]
      b5a489fc
    • G
      Cache check if `default_scope` has been overridden. · 52b2ab9e
      Guo Xiang Tan 提交于
      Benchmark Script:
      ```
      begin
        require 'bundler/inline'
      rescue LoadError => e
        $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
        raise e
      end
      
      gemfile(true) do
        source 'https://rubygems.org'
        # gem 'rails', github: 'rails/rails', ref: 'f1f0a3f8'
        gem 'rails', path: '~/rails'
        gem 'arel', github: 'rails/arel', branch: 'master'
        gem 'rack', github: 'rack/rack', branch: 'master'
        gem 'sass'
        gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
        gem 'sprockets', github: 'rails/sprockets', branch: 'master'
        gem 'pg'
        gem 'benchmark-ips'
      end
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection('postgres://postgres@localhost:5432/rubybench')
      
      ActiveRecord::Migration.verbose = false
      
      ActiveRecord::Schema.define do
        create_table :users, force: true do |t|
          t.string :name, :email
          t.timestamps null: false
        end
      end
      
      class User < ActiveRecord::Base; end
      
      attributes = {
        name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        email: "foobar@email.com",
      }
      
      1000.times { User.create!(attributes) }
      
      Benchmark.ips(5, 3) do |x|
        x.report('where with hash') { User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.report('where with string') { User.where("users.name = ?", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.compare!
      end
      
      key =
        if RUBY_VERSION < '2.2'
          :total_allocated_object
        else
          :total_allocated_objects
        end
      
      before = GC.stat[key]
      User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
      after = GC.stat[key]
      puts "Total Allocated Object: #{after - before}"
      ```
      
      Stackprof output truncated.
      ```
      TOTAL    (pct)     SAMPLES    (pct)     FRAME
         52  (10.6%)          10   (2.0%)     ActiveRecord::Scoping::Default::ClassMethods#build_default_scope
      ```
      
      Before:
      ```
      Calculating -------------------------------------
           where with hash     2.789k i/100ms
         where with string     4.407k i/100ms
      -------------------------------------------------
           where with hash     29.170k (± 1.9%) i/s -    147.817k
         where with string     46.954k (± 2.7%) i/s -    237.978k
      
      Comparison:
         where with string:    46954.3 i/s
           where with hash:    29169.9 i/s - 1.61x slower
      
      Total Allocated Object: 85
      Calculating -------------------------------------
                       all    16.773k i/100ms
      -------------------------------------------------
                       all    186.102k (± 3.6%) i/s -    939.288k
      ```
      
      After:
      ```
      Calculating -------------------------------------
           where with hash     3.014k i/100ms
         where with string     4.623k i/100ms
      -------------------------------------------------
           where with hash     31.524k (± 1.3%) i/s -    159.742k
         where with string     49.948k (± 2.3%) i/s -    249.642k
      
      Comparison:
         where with string:    49948.3 i/s
           where with hash:    31524.3 i/s - 1.58x slower
      
      Total Allocated Object: 84
      Calculating -------------------------------------
                       all    20.139k i/100ms
      -------------------------------------------------
                       all    227.860k (± 2.5%) i/s -      1.148M
      ```
      52b2ab9e
    • G
      Reduce calls to stringify_keys. · 47e06c98
      Guo Xiang Tan 提交于
      Stackprof output truncated.
      ```
      TOTAL    (pct)     SAMPLES    (pct)     FRAME
        23   (4.7%)          12   (2.4%)     Hash#transform_keys
        11   (2.2%)          11   (2.2%)     block in Hash#transform_keys
        30   (6.1%)           7   (1.4%)     Hash#stringify_keys
      ```
      
      Benchmark Script:
      ```
      begin
        require 'bundler/inline'
      rescue LoadError => e
        $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
        raise e
      end
      
      gemfile(true) do
        source 'https://rubygems.org'
        gem 'rails', path: '~/rails' # master against ref "f1f0a3f8"
        gem 'arel', github: 'rails/arel', branch: 'master'
        gem 'rack', github: 'rack/rack', branch: 'master'
        gem 'sass'
        gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'master'
        gem 'sprockets', github: 'rails/sprockets', branch: 'master'
        gem 'pg'
        gem 'benchmark-ips'
      end
      
      require 'active_record'
      require 'benchmark/ips'
      
      ActiveRecord::Base.establish_connection('postgres://postgres@localhost:5432/rubybench')
      
      ActiveRecord::Migration.verbose = false
      
      ActiveRecord::Schema.define do
        create_table :users, force: true do |t|
          t.string :name, :email
          t.timestamps null: false
        end
      end
      
      class User < ActiveRecord::Base; end
      
      attributes = {
        name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
        email: "foobar@email.com",
      }
      
      1000.times { User.create!(attributes) }
      
      Benchmark.ips(5, 3) do |x|
        x.report('where with hash') { User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.report('where with string') { User.where("users.name = ?", "Lorem ipsum dolor sit amet, consectetur adipiscing elit.") }
        x.compare!
      end
      
      key =
        if RUBY_VERSION < '2.2'
          :total_allocated_object
        else
          :total_allocated_objects
        end
      
      before = GC.stat[key]
      User.where(name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
      after = GC.stat[key]
      puts "Total Allocated Object: #{after - before}"
      ```
      
      Before:
      ```
      Calculating -------------------------------------
           where with hash     2.796k i/100ms
         where with string     4.338k i/100ms
      -------------------------------------------------
           where with hash     29.177k (± 1.5%) i/s -    148.188k
         where with string     47.419k (± 2.8%) i/s -    238.590k
      
      Comparison:
         where with string:    47419.0 i/s
           where with hash:    29176.6 i/s - 1.63x slower
      
      Total Allocated Object: 85
      ```
      
      After:
      ```
      Calculating -------------------------------------
           where with hash     2.895k i/100ms
         where with string     4.416k i/100ms
      -------------------------------------------------
           where with hash     30.758k (± 2.0%) i/s -    156.330k
         where with string     47.708k (± 2.6%) i/s -    238.464k
      
      Comparison:
         where with string:    47707.9 i/s
           where with hash:    30757.7 i/s - 1.55x slower
      
      Total Allocated Object: 84
      ```
      47e06c98
    • R
      Merge pull request #21521 from yui-knk/fix/ar_task_desc · ff21abee
      Richard Schneeman 提交于
      [ci skip] Replace `AR` with `Active Record` in task desc
      ff21abee
    • Y
      [ci skip] Replace `AR` with `Active Record` in task desc · 5adaa9dc
      yui-knk 提交于
      Many user look `desc` of rake task and they are not familiar with `AR`.
      `Active Record` is more familiar word.
      5adaa9dc
    • Y
      raise LoadError when a non-existent file or directory is specified to the test runner · 084a3908
      yuuji.yaginuma 提交于
      Currently, if a file or directory that does not exist was specified in the test runner,
      that argument is ignored.
      This commit has been modified to cause an error if there is no file or directory.
      084a3908
  3. 06 9月, 2015 2 次提交