diff options
8 files changed, 17 insertions, 29 deletions
diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb index cf8c0159e2..8c16308ce7 100644 --- a/actionpack/lib/action_controller/renderer.rb +++ b/actionpack/lib/action_controller/renderer.rb @@ -74,7 +74,7 @@ module ActionController # * <tt>:partial</tt> - See <tt>ActionView::PartialRenderer</tt> for details. # * <tt>:file</tt> - Renders an explicit template file. Add <tt>:locals</tt> to pass in, if so desired. # It shouldn’t be used directly with unsanitized user input due to lack of validation. - # * <tt>:inline</tt> - Renders a ERB template string. + # * <tt>:inline</tt> - Renders an ERB template string. # * <tt>:plain</tt> - Renders provided text and sets the content type as <tt>text/plain</tt>. # * <tt>:html</tt> - Renders the provided HTML safe string, otherwise # performs HTML escape on the string first. Sets the content type as <tt>text/html</tt>. diff --git a/actionview/test/ujs/public/vendor/jquery-2.2.0.js b/actionview/test/ujs/public/vendor/jquery-2.2.0.js index 1e0ba99740..2c545b8ff3 100644 --- a/actionview/test/ujs/public/vendor/jquery-2.2.0.js +++ b/actionview/test/ujs/public/vendor/jquery-2.2.0.js @@ -5578,7 +5578,7 @@ var iframe, }; /** - * Retrieve the actual display of a element + * Retrieve the actual display of an element * @param {String} name nodeName of the element * @param {Object} doc Document object */ diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index c2087b8216..202187a047 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -522,7 +522,7 @@ module ActiveRecord end def default_uniqueness_comparison(attribute, value, klass) # :nodoc: - case_sensitive_comparison(attribute, value) + attribute.eq(value) end def case_sensitive_comparison(attribute, value) # :nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index d99c9b9d02..a518b897a0 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -461,15 +461,16 @@ module ActiveRecord def default_uniqueness_comparison(attribute, value, klass) # :nodoc: column = column_for_attribute(attribute) - if column.collation && !column.case_sensitive? + if column.collation && !column.case_sensitive? && !value.nil? ActiveSupport::Deprecation.warn(<<~MSG.squish) Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1. To continue case sensitive comparison on the :#{attribute.name} attribute in #{klass} model, pass `case_sensitive: true` option explicitly to the uniqueness validator. MSG + attribute.eq(Arel::Nodes::Bin.new(value)) + else + super end - - super end def case_sensitive_comparison(attribute, value) # :nodoc: diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 72ccf7739f..a09b5f0e96 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -93,7 +93,7 @@ module ActiveRecord # record or pass <tt>returning: false</tt> to omit the clause. # # [:unique_by] - # (Postgres and SQLite only) In a table with more than one unique constaint or index, + # (Postgres and SQLite only) In a table with more than one unique constraint or index, # new records may considered duplicates according to different criteria. By default, # new rows will be skipped if they violate _any_ unique constraint/index. By defining # <tt>:unique_by</tt>, you can skip rows that would create duplicates according to the given @@ -218,7 +218,7 @@ module ActiveRecord # record or pass <tt>returning: false</tt> to omit the clause. # # [:unique_by] - # (Postgres and SQLite only) In a table with more than one unique constaint or index, + # (Postgres and SQLite only) In a table with more than one unique constraint or index, # new records may considered duplicates according to different criteria. For MySQL, # an upsert will take place if a new record violates _any_ unique constraint. For # Postgres and SQLite, new rows will replace existing rows when the new row has the diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index dc1be73a60..3172aa2078 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -60,9 +60,7 @@ module ActiveRecord comparison = relation.bind_attribute(attribute, value) do |attr, bind| return relation.none! if bind.unboundable? - if bind.nil? - attr.eq(bind) - elsif !options.key?(:case_sensitive) + if !options.key?(:case_sensitive) || bind.nil? klass.connection.default_uniqueness_comparison(attr, bind, klass) elsif options[:case_sensitive] klass.connection.case_sensitive_comparison(attr, bind) diff --git a/activerecord/test/cases/migration/foreign_key_test.rb b/activerecord/test/cases/migration/foreign_key_test.rb index da82f62406..ba21923d79 100644 --- a/activerecord/test/cases/migration/foreign_key_test.rb +++ b/activerecord/test/cases/migration/foreign_key_test.rb @@ -20,7 +20,9 @@ if ActiveRecord::Base.connection.supports_foreign_keys? end end - module ForeignKeyChangeColumnSharedTest + class ForeignKeyChangeColumnTest < ActiveRecord::TestCase + self.use_transactional_tests = false + class Rocket < ActiveRecord::Base has_many :astronauts end @@ -141,17 +143,7 @@ if ActiveRecord::Base.connection.supports_foreign_keys? end end - class ForeignKeyChangeColumnTest < ActiveRecord::TestCase - include ForeignKeyChangeColumnSharedTest - - self.use_transactional_tests = false - end - - class ForeignKeyChangeColumnWithPrefixTest < ActiveRecord::TestCase - include ForeignKeyChangeColumnSharedTest - - self.use_transactional_tests = false - + class ForeignKeyChangeColumnWithPrefixTest < ForeignKeyChangeColumnTest setup do ActiveRecord::Base.table_name_prefix = "p_" end @@ -161,11 +153,7 @@ if ActiveRecord::Base.connection.supports_foreign_keys? end end - class ForeignKeyChangeColumnWithSuffixTest < ActiveRecord::TestCase - include ForeignKeyChangeColumnSharedTest - - self.use_transactional_tests = false - + class ForeignKeyChangeColumnWithSuffixTest < ForeignKeyChangeColumnTest setup do ActiveRecord::Base.table_name_suffix = "_p" end diff --git a/guides/source/active_record_querying.md b/guides/source/active_record_querying.md index 30493038e7..c9db99ca1d 100644 --- a/guides/source/active_record_querying.md +++ b/guides/source/active_record_querying.md @@ -611,7 +611,8 @@ If you want to call `order` multiple times, subsequent orders will be appended t Client.order("orders_count ASC").order("created_at DESC") # SELECT * FROM clients ORDER BY orders_count ASC, created_at DESC ``` -WARNING: If you are using **MySQL 5.7.5** and above, then on selecting fields from a result set using methods like `select`, `pluck` and `ids`; the `order` method will raise an `ActiveRecord::StatementInvalid` exception unless the field(s) used in `order` clause are included in the select list. See the next section for selecting fields from the result set. + +WARNING: In most database systems, on selecting fields with `distinct` from a result set using methods like `select`, `pluck` and `ids`; the `order` method will raise an `ActiveRecord::StatementInvalid` exception unless the field(s) used in `order` clause are included in the select list. See the next section for selecting fields from the result set. Selecting Specific Fields ------------------------- |