1. 27 6月, 2019 1 次提交
    • E
      Load initial database.yml once, and warn if we can't create tasks · df6b0de7
      eileencodes 提交于
      For multiple databases we attempt to generate the tasks by reading the
      database.yml before the Rails application is booted. This means that we
      need to strip out ERB since it could be reading Rails configs.
      
      In some cases like https://github.com/rails/rails/issues/36540 the ERB
      is too complex and we can't overwrite with the DummyCompilier we used in
      https://github.com/rails/rails/pull/35497. For the complex causes we
      simply issue a warning that says we couldn't infer the database tasks
      from the database.yml.
      
      While working on this I decided to update the code to only load the
      database.yml once initially so that we avoid having to issue the same
      warning multiple times. Note that this had no performance impact in my
      testing and is merely for not having to save the error off somewhere.
      Also this feels cleaner.
      
      Note that this will not break running tasks that exist, it will just
      mean that tasks for multi-db like `db:create:other_db` will not be
      generated. If the database.yml is actually unreadable it will blow up
      during normal rake task calls.
      
      Fixes #36540
      df6b0de7
  2. 25 6月, 2019 1 次提交
    • R
      Merge pull request #36210 from... · b65f8865
      Rafael França 提交于
      Merge pull request #36210 from vishaltelangre/raise-record-invalid-when-associations-fail-to-save-due-to-uniqueness-failure
      
      Fix: ActiveRecord::RecordInvalid is not raised when an associated record fails to #save! due to uniqueness validation failure
      b65f8865
  3. 24 6月, 2019 1 次提交
  4. 23 6月, 2019 1 次提交
  5. 22 6月, 2019 3 次提交
  6. 21 6月, 2019 5 次提交
  7. 20 6月, 2019 12 次提交
  8. 19 6月, 2019 3 次提交
    • R
      Add test cases to ensure deterministic order for ordinal methods · 2c96b046
      Ryuta Kamizono 提交于
      Before 1340498d, `order` with no-op value (e.g. `nil`, `""`) had broken
      the contract of ordinal methods, which returns a result deterministic
      ordered.
      2c96b046
    • B
      Allow using env var to specify pidfile · 2e5ec9a6
      Ben Thorner 提交于
      Previously it was only possible to specify the location of the pidfile
      for the 'rails server' command with the '-P' flag. This adds support for
      specifying the pidfile using a PIDFILE env var, which can still be
      overridden by the '-P' flag and with the default pidfile path unchanged.
      
      The motivation for this feature comes from using Docker to run multiple
      instances of the same rails app. When developing a rails app with
      Docker, it's common to bind-mount the rails root directory in the
      running container, so that changes to files are shared between the
      container and the host. However, this doesn't work so well with the
      pidfile and it's necessary to (remember to) add a '-P' flag to the
      'rails server' command line; being able to specify this flag using an
      env var would make developing with Rails+Docker a bit simpler.
      2e5ec9a6
    • K
      Merge pull request #35891 from Shopify/schema-cache-deduplication · aae270de
      Kasper Timm Hansen 提交于
      Deduplicate various Active Record schema cache structures
      aae270de
  9. 18 6月, 2019 3 次提交
    • R
      Merge pull request #36508 from kamipo/avoid_getutc · aeba121a
      Ryuta Kamizono 提交于
      Avoid redundant `time.getutc` call if it is already utc time object
      aeba121a
    • R
      Merge pull request #36482 from Shopify/fix-translation-helper-default-hash · c65acad0
      Rafael França 提交于
      Fix TranslationHelper#translate handling of Hash defaults
      c65acad0
    • R
      Avoid redundant `time.getutc` call if it is already utc time object · d29d4598
      Ryuta Kamizono 提交于
      Currently `type.serialize` and `connection.{quote|type_cast}` for a time
      object always does `time.getutc` call regardless of whether it is
      already utc time object or not, that duplicated proccess
      (`connection.type_cast(type.serialize(time))`) allocates extra/useless
      time objects for each type casting.
      
      This avoids that redundant `time.getutc` call if it is already utc time
      object. In the case of a model has timestamps (`created_at` and
      `updated_at`), it avoids 6,000 time objects allocation for 1,000 times
      `model.save`.
      
      ```ruby
      ObjectSpace::AllocationTracer.setup(%i{path line type})
      
      pp ObjectSpace::AllocationTracer.trace {
        1_000.times { User.create }
      }.select { |k, _| k[0].end_with?("quoting.rb", "time_value.rb") }
      ```
      
      Before (c104bfe4):
      
      ```
      {["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        203,
        :T_ARRAY]=>[1004, 0, 778, 0, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        220,
        :T_STRING]=>[2, 0, 2, 1, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        209,
        :T_ARRAY]=>[8, 0, 8, 1, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        57,
        :T_ARRAY]=>[4, 0, 4, 1, 1, 0],
       ["~/rails/activemodel/lib/active_model/type/helpers/time_value.rb",
        17,
        :T_DATA]=>[4000, 0, 3096, 0, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        120,
        :T_DATA]=>[2000, 0, 1548, 0, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        126,
        :T_STRING]=>[4000, 0, 3096, 0, 1, 0]}
      ```
      
      After (this change):
      
      ```
      {["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        203,
        :T_ARRAY]=>[1004, 0, 823, 0, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        220,
        :T_STRING]=>[2, 0, 2, 1, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        209,
        :T_ARRAY]=>[8, 0, 8, 1, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        57,
        :T_ARRAY]=>[4, 0, 4, 1, 1, 0],
       ["~/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb",
        126,
        :T_STRING]=>[2000, 0, 1638, 0, 1, 0]}
      ```
      d29d4598
  10. 17 6月, 2019 4 次提交
  11. 16 6月, 2019 3 次提交
  12. 15 6月, 2019 3 次提交