1. 13 5月, 2020 5 次提交
    • R
      Fix type casting aggregated values on association's attributes · 5f59eac2
      Ryuta Kamizono 提交于
      Follow up of #39255.
      
      Previously aggregation functions only use the model's attribute types on
      the relation for type cast, this will be looking up association's
      attribute and type caster if a column name is table name qualified.
      
      Fixes #39248.
      5f59eac2
    • E
      Use binread instead of setting file mode manually · 96a1a2a3
      Eugene Kenny 提交于
      Followup to b3102205.
      96a1a2a3
    • J
      Avoid confliting Kernel-named scopes on Relation · 1b773bca
      John Hawthorn 提交于
      A previous change made singleton methods eagerly define their relation
      methods if it shared a name with a method on Kernel. This caused issues
      with a few methods which were both defined on Kernel and on
      AcitveRecord::Relation.
      
      This commit avoids defining the method if it exists on AR::Relation.
      1b773bca
    • E
      Remove implementation of unchecked_serialize · 6833bf4d
      eileencodes 提交于
      Since we're checking `serializable?` in the new `HomogeneousIn`
      `serialize` will no longer raise an exception. We implemented
      `unchecked_serialize` to avoid raising in these cases, but with some of
      our refactoring we no longer need it.
      
      I discovered this while trying to fix a query in our application that
      was not properly serializing binary columns. I discovered that in at
      least 2 of our active model types we were not calling the correct
      serialization. Since `serialize` wasn't aliased to `unchecked_serialize`
      in `ActiveModel::Type::Binary` and `ActiveModel::Type::Boolean` (I
      didn't check others but pretty sure all the AM Types are broken) the SQL
      was being treated as a `String` and not the correct type.
      
      This caused Rails to incorrectly query by string values. This is
      problematic for columns storing binary data like our emoji columns at
      GitHub. The test added here is an example of how the Binary type was
      broken previously. The SQL should be using the hex values, not the
      string value of "🥦" or other emoji.
      
      We still have the problem `unchecked_serialize` was supposed to fix -
      that `serialize` shouldn't validate data, just convert it. We'll be
      fixing that in a followup PR so for now we should use `serialize` so we
      know all the values are going through the right serialization for their
      SQL.
      6833bf4d
    • R
      Fix `minimum` and `maximum` on time zone aware attributes · 11751b2e
      Ryuta Kamizono 提交于
      This is the opposite direction of #39039.
      
      #39111 fixes `minimum` and `maximum` on date columns with type casting
      by column type on the database. But column type has no information for
      time zone aware attributes, it means that attribute type should always
      be precedence over column type. I've realized that fact in the related
      issue report #39248.
      
      I've reverted the expectation of #39039, to make time zone aware
      attributes works.
      11751b2e
  2. 12 5月, 2020 1 次提交
  3. 11 5月, 2020 3 次提交
    • A
      Fix for reading binary file on Windows · b3102205
      Aidan Haran 提交于
      b3102205
    • J
      Optimize dangerous_attribute_method? · 0c79308d
      Jean Boussier 提交于
      Profiling our application boot shows this method at 1.3% of boot time:
      
      ```
      ActiveRecord::AttributeMethods::ClassMethods#dangerous_attribute_method? (/tmp/bundle/ruby/2.7.0/bundler/gems/rails-4919b459d946/activerecord/lib/active_record/attribute_methods.rb:100)
        samples:     5 self (0.0%)  /    866 total (1.3%)
        callers:
           866  (  100.0%)  ActiveRecord::AttributeMethods::PrimaryKey::ClassMethods#dangerous_attribute_method?
        callees (861 total):
           861  (  100.0%)  ActiveRecord::AttributeMethods::ClassMethods#method_defined_within?
      ```
      
      [A quick benchmark](https://gist.github.com/casperisfine/0ce1161253ab643f5f15ff63e901b818) shows
      that we can make it 2 to 3 times faster by precomputing the list of
      dangerous methods, and doing a simple set lookup.
      
      Of course this isn't strictly equivalent, as it's no longer dynamic, so if you
      include a module in `AR::Base` after the list was computed, new dangerous
      methods won't be considered. But at the same time, if the list was already computed,
      it means you defined attribute methods before AR::Base was fully initialized.
      
      `dangerous_class_method?` is pretty much invisible on profiles, but
      I applied the same optimization to it for consistency's sake.
      0c79308d
    • Y
      Address `InnerJoinAssociationTest#test_eager_load_with_string_joins` failure with mysql2 · 950a453d
      Yasuo Honda 提交于
      `ReadOnlyTest#test_field_named_field` performs implicit commit the transaction by `ReadOnlyTest#setup`
      because of the MySQL database behavior.
      
      This commit addresses the failure at https://buildkite.com/rails/rails/builds/68962#68213887-1cef-4f76-9c95-aebc8799c806
      Here are minimum steps to reproduce:
      
      ```ruby
      % ARCONN=mysql2 bin/test test/cases/readonly_test.rb test/cases/dirty_test.rb test/cases/associations/inner_join_association_test.rb \
      -n "/^(?:ReadOnlyTest#(?:test_has_many_with_through_is_not_implicitly_marked_readonly)|DirtyTest#(?:test_field_named_field)|InnerJoinAssociationTest#(?:test_eager_load_with_string_joins))$/" --seed 50855
      Using mysql2
      Run options: -n "/^(?:ReadOnlyTest#(?:test_has_many_with_through_is_not_implicitly_marked_readonly)|DirtyTest#(?:test_field_named_field)|InnerJoinAssociationTest#(?:test_eager_load_with_string_joins))$/" --seed 50855
      
      ..F
      
      Failure:
      InnerJoinAssociationTest#test_eager_load_with_string_joins [/Users/yahonda/src/github.com/rails/rails/activerecord/test/cases/associations/inner_join_association_test.rb:87]:
      Expected: 3
        Actual: 4
      
      bin/test test/cases/associations/inner_join_association_test.rb:82
      
      Finished in 0.114674s, 26.1611 runs/s, 26.1611 assertions/s.
      3 runs, 3 assertions, 1 failures, 0 errors, 0 skips
      ```
      
      References:
      - "13.3.3 Statements That Cause an Implicit Commit"
      https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html
      950a453d
  4. 10 5月, 2020 9 次提交
  5. 09 5月, 2020 3 次提交
  6. 08 5月, 2020 1 次提交
  7. 07 5月, 2020 5 次提交
  8. 06 5月, 2020 8 次提交
  9. 05 5月, 2020 5 次提交