2015/09/22分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Ensure aliased attributes passed to
selectare quoted if usingfrom ActiveRecord::Tasks::MySQLDatabaseTasksfails if shellout to mysql commands (likemysqldump) is not successful.
Move ActiveRecord::Type to ActiveModel
Active Record / Active Modelの修正です。
attributes API 用の ActiveRecord::Type配下のクラスを、Active Record配下からActive Model配下に移動しています。
とりあえずまとめて全部移動しており、以降のコミットで細かい調整が行われています。
TypeMap and HashLookupTypeMap shouldn't be in Active Model
Active Record / Active Modelの修正です。
Type::HashLookupTypeMapクラス、Type::TypeMapクラスをActive Model配下からActive Record配下に戻しています。
上記クラスはSQL typeから適切なtype objectに変換処理を行う為のクラスであり、Active Record配下にあるのが適切だろう、という事で戻したようです。
Active Record / Active Modelの修正です。
不要なスペースやrequireの削除、activerecord/lib/active_record/type.rbにまとめて定義していたDate / Time用のクラスを別ファイルへの切り出し等を行っています。
Simplify the implementation of Active Model's type registry
activemodel/lib/active_model/type/registry.rb、
activerecord/lib/active_record/type/adapter_specific_registry.rbの修正です。
Active Modelのtype registry処理のリファクタリングを行っています。
Active Model側で意識するべきではないデコレート処理等をActive Recordのクラス(AdapterSpecificRegistry)に移動、及び不要な処理の削除を行っています。
Active RecordのType::AdapterSpecificRegistryクラスはActiveModel::Type::Registryを継承しており、大分密に紐付いてしまっている感あります。
Move the appropriate type tests to the Active Model suite
Active Record / Active Modelの修正です。
type objectに関するテストを、コードに合わせてActive RecordからActive Modelに移動しています。
Remove no-op options being passed in AM type registrations
activemodel/lib/active_model/type.rbの修正です。
type objectのregister処理から、不要なoverrideオプションを削除しています。
overrideオプションはActive Recordの登録処理でのみ必要なオプションの為、との事です。
We still need the Helpers constant in the ActiveRecord namespace
activerecord/lib/active_record/type.rbの修正です。
ActiveModel::Type::HelpersをHelpers定数として定義しています。 Active Model配下のmoduleを使用している、という事を明確にする為、のようなのですが、よくわからなかった…。
Added assertion for error messages for redirection to nil and params
actionpack/test/controller/redirect_test.rbの修正です。
redirectメソッドにnil、paramsを指定した場合のテストで、エラーメッセージについても確認するようテストを修正しています。
Require dependencies from stdlib in the Decimal type
activemodel/lib/active_model/type/decimal.rbの修正です。
不足していたbigdecimal/utilのrequireを追加しています。
Fix another implicit dependency of the AM test suite
activemodel/test/cases/types_test.rbの修正です。
不足していたactive_support/core_ext/numeric/timeのrequireを追加しています。
Ensure aliased attributes passed to select are quoted if using from
activerecord/lib/active_record/relation/query_methods.rbの修正です。
alias_attributeで定義したattributeを使用してselectメソッドを呼び出した場合に、attribute名が正しくエスケープされないバグがあったのを修正しています。
例。
ActiveRecord::Schema.define do create_table :test, force: true do |t| t.integer :desc end end class Test < ActiveRecord::Base alias_attribute :description, :desc default_scope { select(:description) } end
Test.from(Test.where(desc: 10), Test.table_name).to_a.size # => SELECT desc FROM (SELECT `test`.`desc` FROM `test` WHERE `test`.`desc` = 10) test
Skip the test added in 9cc324a on buggy versions of SQlite
activerecord/test/cases/relation_test.rbの修正です。
Ensure aliased attributes passed to select are quoted if using from で追加したテストが、古いSQLite3だと動かない(クオート処理が正しく動作しない)問題があるので、古いSQLite3ではテストを行わないよう修正しています。
SQLiteのクオート処理の問題については、Ensure symbols passed to select are always quoted · rails/rails@0ef7e73 参照。
Eliminate test_tables_quoting following seems to be left in #21687
activerecord/test/cases/adapters/mysql/mysql_adapter_test.rbの修正です。
Refactor table_exists? in AbstractMysqlAdapter の対応により不要になったテストを削除しています。
cache the new type object on the stack
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Type.registerメソッドで、一度Mime.const_setでMimeを登録した後、再度Mime.const_getで登録した値を取得していたのを、登録時に使用した値を変数で保持して、それをそのまま使用するよう修正しています。
deprecate accessing mime types via constants
Action Packの修正です。
mime typesに定数でアクセスするのがdeprecateになりました。今後は、TYPES hashアクセス経由でアクセスする必要があります。
# before Mime::HTML # after Mime::Type[:HTML]
定数だとキャッシュ出来ないし、mime typeとして登録していないクラスを使用しようとして、全然関係無いクラスを取得してしまう、という問題が起きてしまったりするので、Hash経由でのアクセスに変更したとの事です。
stop calling deprecated methods
Action Packの修正です。
先の対応の続きです。mime typesを使用するのに定数を使用していたのを、Mime::Typeを使用するよう修正しています。
actionpack/lib/action_controller/metal/mime_responds.rbの修正です。
mime typeの初期化処理で、upcaseとto_symの順番を入れ替えています。
- mimes.each { |mime| @responses[Mime::Type[mime.to_sym.upcase]] = nil }
+ mimes.each { |mime| @responses[Mime::Type[mime.upcase.to_sym]] = nil }
んー、これは何ででしょうねえ。Symbolはupcase出来ないのかなーと思ったら、そうでも無いですし。
update changelog for mime changes
actionpack/CHANGELOG.mdの修正です。
deprecate accessing mime types via constants の対応について、CHANGELOGに追加しています。
change inheritance to composition
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Mime::MimesクラスがArrayを継承していたのをやめて、代わりにEnumerableをincludeするよう修正しています。
キャッシュした値を使用出来るようにする為に、独自で各メソッドを定義しています。
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Mime::Type#==メソッドでblank?メソッドを使用していたのを、使用しないよう修正しています。
- return false if mime_type.blank? + return false unless mime_type
Mime::Typeは独自にmethod_missingメソッドを実装しており、blank?を使用するとそちらの処理が呼ばれてしまい、期待通りのチェックが出来ないので、使用しないよう修正したようです。
actionpack/lib/action_dispatch/http/mime_type.rb、
actionpack/lib/action_dispatch/http/mime_types.rbの修正です。
全てのmime typeを意味するMime::Type::Allクラスを新規に作成しています。
compare arrays not set objects.
actionview/test/template/lookup_context_test.rbの修正です。
Mime::SETと@lookup_context.formatsを比較する際、Mime::SETをto_aでArrayに変換してから値を比較するよう修正しています。
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Typeクラスからhtml_types変数を削除しています。
元々、Mime All を表す為に使用していた変数だったのですが、allは、それ自体を表すクラス(Mime::Type::All)を別に作成したので、こちらでは不要との事で削除しています。
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Mime::Typeクラスのオブジェクトでblank?メソッドを使用している箇所が残っていたので、削除しています。
drop array allocations on Mime::Type#=~
actionpack/lib/action_dispatch/http/mime_type.rbの修正です。
Mime::Type#=~メソッドで、不要なArrayオブジェクトを作成しないようにリファクタリングしています。
- (@synonyms + [ self ]).any? do |synonym| - synonym.to_s =~ regexp - end + @synonyms.any? { |synonym| synonym.to_s =~ regexp } || @string =~ regexp
@synonyms + [ self ]でArrayオブジェクトが生成されてしまっていた為、@synonymsとselfを別にチェックするようにしたようです。
Fix a typo: Mime::Types should be Mime::Type [ci skip]
actionpack/CHANGELOG.mdの修正です。
Mime::TypeをMime::Typesにタイポしていたのを修正しています。
Correcting output of number_to_percentage example in number_helper [ci skip]
actionview/lib/action_view/helpers/number_helper.rb、
activesupport/lib/active_support/number_helper.rbのdocの修正です。
number_to_percentageメソッドのdoc内のexampleの実行結果が、実際の結果と違っていたのを修正してます。
Merge pull request #21678 from ronakjangir47/array_to_formatted_s_docs
activesupport/lib/active_support/core_ext/array/conversions.rbのdocの修正です。
Array#to_formatted_sメソッドのdocに、exampleを追加しています。
Correcting output of file_field with multiple attribute option [ci skip]
actionview/lib/action_view/helpers/form_helper.rbのdocの修正です。
file_fieldメソッドにmultipleオプションを指定した場合の実行結果が、実際の結果と異なっていたのを修正しています。
Merge pull request #20569 from theSteveMitchell/master
activerecord/lib/active_record/tasks/mysql_database_tasks.rbの修正です。
ActiveRecord::Tasks::MySQLDatabaseTasksで、mysqlのコマンド(mysqldump等)が失敗した際に、rakeタスク自体がfailするよう修正しています。
activerecord/test/cases/adapters/mysql/explain_test.rbの修正です。
bin/testをsqlite3_memで実行した場合に、テストの実行でエラーになっていたのを修正しています。
MysqlAdapterだけで実施すべきテストが実行されてしまっていた為、該当のテストクラスの親クラスにMysqlTestCaseを設定し、MysqlAdapterでだけテストが実行されるよう修正しています。
rails guideのRails Routing from the Outside Inの修正です。
routes.rbをconfig/routes.rbに修正しています。
Removed mocha from Railites PluginGeneratorTest
Railitesのテストの修正です。
mock処理にmochaを使っていたのをやめて、rails内のヘルパーメソッドを使用するよう修正しています。
activemodel/lib/active_model/validations/confirmation.rb、
activemodel/test/cases/attribute_assignment_test.rbの修正です。
confirmationをconfimationにタイポしていたのと、objectをobejctにタイポしていたのをまとめて修正しています。