2017/01/04分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Respect precision option for arrays of timestamps.
- Raise
ArgumentErrorwhen passing anActiveRecord::Baseinstance to.find,.exists?and.update. - Compare deserialized values for
PostgreSQL::OID::Hstoretypes when callingActiveRecord::Dirty#changed_in_place? - Remove deprecated db:test:clone* tasks
- Deprecate passing
nametoindexes. - Raise error when has_many through is defined before through association
- Remove deprecated
config.static_cache_control. - Remove deprecated
config.serve_static_files. - Remove deprecated file
rails/rack/debugger. - Remove deprecated tasks:
rails:update,rails:template,rails:template:copy,rails:update:configsandrails:update:bin. - Remove deprecated
CONTROLLERenvironment variable forroutestask. - Make
Rails.envfall back todevelopmentwhenRAILS_ENVandRACK_ENVis an empty string.
Clarify Bi-directional Associations docs
rails guideのActive Record Associationsの修正です
Bi-directional Associationsの項に、bi-directional associationsを定義する際に使用できるオプションについての説明、inverse_ofオプションについての詳細な説明等を追加しています。
Merge pull request #27491 from kamipo/add_missing_emit_warning
activerecord/lib/active_record/attribute_methods/dirty.rbの修正です。
Deprecate the behavior of AR::Dirty inside of after_(create|update|save) callbacksの対応でchanged?メソッドが呼ばれた場合にwarningが出す処理が漏れていたので、追加しています。
Merge pull request #27435 from kamipo/follow_up_25307
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rbの修正です。
Active RecordがサポートするMySQLのバージョンを5.1.10以上にするようversionチェック処理を修正しています。
schema dump処理で使用しているinformation_schema.referential_constraints tableはMySQL 5.1.10で追加された、かつ、MySQL 5.0も5.1もEOLは過ぎている(5.0は2011/12, 5.1は2013/12)為、5.1.10以上のみサポートするようにしたとの事です。
Consistently apply adapter behavior when serializing arrays
activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb、
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rbの修正です。
PostgreSQLでtimestamps型のArrayを使用してた場合に、precisionオプションに指定した値が反映されないバグがあったのを修正しています。
Merge pull request #27335 from kamipo/remove_duplicated_model_definition
activerecord/test/cases/base_test.rbの修正です。
重複していたテスト用のmodelの定義を削除しています。
Merge pull request #27363 from amatsuda/refined_array_sum
activesupport/lib/active_support/core_ext/enumerable.rbの修正です。
RailsでArray#sumを定義する際に、Ruby本体のArray#sumにorig_sumという別名をつけて使用出来るようにしていたのですが、そのorig_sumを定義する際に、refineを使用するよう修正しています。
- class Array
- alias :orig_sum :sum
+ # Using Refinements here in order not to expose our internal method
+ using Module.new {
+ refine Array do
+ alias :orig_sum :sum
+ end
+ }
+ class Array
元のやり方だとRails内部で使用する為に定義しているArray#orig_sumメソッドがRailsの外部から参照出来てしまう為、refineを使用してファイルの内部でだけ使用できるようにしたとの事です。なるほど。
Merge pull request #24814 from vipulnsward/24811-fix-double-tasks
railties/lib/rails/tasks/statistics.rakeの修正です。
statsの対処ディレクトリのリストからlib/tasksディレクトリを削除しています。別途libディレクトリが追加されており、lib/task配下にあるファイルがlib、lib/tasks両方の結果に含まれてしまう為、lib/tasksディレクトリの方は削除したとの事です。んー、これはlibディレクトリの結果にlib/tasksの結果を含まないようにする方が良いような。
Raise ArgumentError when a instance of ActiveRecord::Base is passed to
activerecord/lib/active_record/core.rb、
activerecord/lib/active_record/relation/finder_methods.rbの修正です。
findメソッド及びexists?メソッドにActiveRecord::Baseのインスタンスを渡した場合、ArgumentErrorをraiseするよう修正しています。
元々は動作していたのですが、Rails 4.2でdeprecatedになっており、ついに削除されました。
[ci skip] Find and record the article! ����
activerecord/lib/active_record/persistence.rbのdocの修正です。
reloadメソッドのdocのグラマーの修正を行っています。
Merge pull request #24596 from maclover7/jm-cleanup-3
actionpack/lib/abstract_controller/rendering.rb、
actionpack/lib/action_controller/metal/rendering.rbの修正です。
variantの設定処理をメソッド(_process_variant)に切り出しています。
Compare deserialized values for PostgreSQL::OID::Hstore types
activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rbの修正です。
PostgreSQLでhstore型を使用していた場合に、dirty methodで変更チェックが正しく行われない(チェック処理でdeserializeした値を使用してなかった)バグがあったのを修正しています。
Merge pull request #25927 from y-yagi/remove_needless_warning_for_hstore
activerecord/Rakefileの修正です。
Railsテスト用のDBを作成する際、PostgreSQLが9.1.0以下の場合hstoreに関するwanringを出すようになっていたのを、warningを出さないよう修正しています。Rails 5.0.0以降ではそもそもActive RecordがPostgreSQL 9.1.0以上しかサポートしてない為。
Merge pull request #26352 from kamipo/avoid_to_call_set_inverse_instance_twice
activerecord/lib/active_record/associations/collection_association.rb、
activerecord/lib/active_record/associations/has_many_association.rbの修正です。
has_many associationのcreate、create!、及び、concatメソッドを呼び出した際に、set_inverse_instanceメソッドが2回呼ばれてしまっていたのを、一度だけ呼ぶよう修正しています。
Generate indexed names in input even when objects are not persisted
actionview/lib/action_view/helpers/tags/base.rbの修正です。
tag helper methodで、対象のobjectsが保存されてない場合にindexed nameが生成されないバグがあったのを修正しています。
field_for('comments[]', Comment.new) do |c|
c.text_field :body
# before post[comments][body] # after post[comments][][body]
Merge pull request #25460 from maclover7/jm-uncached
activerecord/test/cases/query_cache_test.rbの修正です。
cacheを有効化した場合、及び、uncachedでcacheをdisableにした場合のテストを追加しています。
activerecord/CHANGELOG.mdの修正です。
zerofillを使用した場合にunsigned型のカラムがsignedとして扱われてしまうバグがあったのを修正したエントリーのグラマーの修正を行っています。
Fix test name deprecated to not_permitted
activerecord/test/cases/finder_test.rbの修正です。
.find及び.exists?メソッドにActiveRecord::Baseのインスタンスを渡した場合のテスト名がxxx_is_deprecatedになっていたのを、not_permitted`に修正しています。Raise ArgumentError when a instance of ActiveRecord::Base is passed toのフォローアップ。
Remove deprecated db:test:clone* tasks
activerecord/lib/active_record/railties/databases.rakeの修正です。
deprecatedになっていたdb:test:clone、db:test:clone_schema、db:test:clone_structure taskを削除しています。
Remove deprecation of using ActiveRecord::Base instance in .update
activerecord/lib/active_record/relation.rbの修正です。
.updateメソッドにActiveRecord::Baseのインスタンスを渡した場合、ArgumentErrorをraiseするよう修正しています。
.find、.exists?同様Rails 4.2からインスタンスを渡すのはdeprecatedになっていた為。
Merge pull request #26689 from kamipo/deprecate_passing_name_to_indexes
Active Recordの修正です。
indexesメソッドのnameオプションがdeprecateにしています。渡せるようになっているもの、現状使用されていない為との事です。
Merge pull request #25626 from maclover7/jm-standardize-ac-readme
actioncable/README.mdの修正です。
Download and Installationの項を追加しています。他のコンポーネントにも同じ項があり、合わせる為に追加したとの事です。
Remove unneeded requires at active record
Active Recordの各ファイルから、使用していないrequireを削除しています。
Merge pull request #25522 from kamipo/fix_select_rows_method_signature_for_consistency
Active Recordの修正です。
select_all, select_one, select_value 及び select_valuesメソッドのシグネチャは(arel, name = nil, binds = [])になっているのに、select_rowsメソッドだけ(sql, name = nil, binds = [])になっていた為、select_rowsのシグネチャも他のメソッドと合わせて(arel, name = nil, binds = [])となるよう修正しています。
Remove unnecessary require statements
activesupport/lib/active_support/core_ext/load_error.rbの修正です。
使用していないrequireを削除しています。
Merge pull request #21233 from mtsmfm/disable-referential-integrity-without-superuser-privileges
activerecord/lib/active_record/connection_adapters/postgresql/referential_integrity.rb、
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。
fixturesのインサート処理等のように、一時的に外部キー制約を無効にしたい場合、PostgreSQLではDISABLE TRIGGER ALLを使用するようになっていたのを、SET CONSTRAINTS ALL DEFERREDが使用出来る場合(9.4.2以上)の場合、そちらを使用するよう修正しています。
SET CONSTRAINTS ALL DEFERREDはDISABLE TRIGGER ALLと異なりsuperuser権限は不要です。
が、PostgreSQLのisolatedテストがコケるようになってしまった為、後ほどrevertされています。
Fix typo s/permited/permitted/
actionview/test/template/url_helper_test.rb、
activerecord/test/cases/relations_test.rbの修正です。
テスト名でpermittedをpermitedにタイポしていたのを修正しています。
Remove deprecated config.static_cache_control
railties/lib/rails/application/configuration.rb、
railties/lib/rails/application/default_middleware_stack.rbの修正です。
deprecatedになっていたconfig.static_cache_controlを削除しています。
Remove deprecated config.serve_static_files
railties/lib/rails/application/configuration.rbの修正です。
deprecatedになっていたconfig.serve_static_filesを削除しています。
Remove deprecated file `rails/rack/debugger
railties/lib/rails/rack/debugger.rbの修正です。
deprecatedになっていたrails/rack/debuggerを削除しています。
Remove deprecated tasks in railties
railties/lib/rails/tasks/framework.rakeの修正です。
deprecatedになっていたrails:update, rails:template, rails:template:copy, rails:update:configs及びrails:update:bin taskを削除しています。
Remove deprecated CONTROLLER environment variable for routes task
railties/lib/rails/tasks/routes.rakeの修正です。
deprecatedになっていたroutes taskのCONTROLLER environmentを指定された際の処理を削除しています。
Remove test to the db:test:clone
railties/test/application/rake_test.rbの修正です。
先ほど削除されたdb:test:clone taskに関するテストを削除しています。
Remove unneeded Deprecation.silence
actionmailer/test/i18n_with_controller_test.rbの修正です。
mail送信のテストから不要なActiveSupport::Deprecation.silenceを削除しています。
actionpack/lib/action_controller/metal.rbの修正です。
deprecatedになっていたActionController::Metal#envメソッドを削除しています。
actionpack/CHANGELOG.mdの修正です。
CHANGELOGのエントリーでActionController::Metalをクラス名だけ(Metal)記載していたのを、module名も記載するよう修正しています。
Remove deprecated ActionController::Metal.call
actionpack/lib/action_controller/metal.rb、
actionpack/lib/action_dispatch/routing/mapper.rbの修正です。
deprecatedになっていたActionController::Metal.callメソッドを削除しています。
Merge pull request #27550 from mtsmfm/fix-generator-command-for-nested-rails-engine
名前がネストしたrails engineで、generatorが生成するファイルのパスに誤りがあったのを修正しています。
例えばbukkits-adminという名前のrails engineだった場合、bin/rails g scaffold User name:string age:integerを実行した場合、bukkits-admin/app/controllers/bukkits/admin/users_controller.rbというファイルが生成されるべきが、bukkits-admin/app/controllers/bukkits/users_controller.rbというファイル(admin部分がロストしている)が生成されてしまっていたのを修正しています。
が、public method(namespaced_path)の挙動を変えてしまっていた為、後ほどrevertされています。
Revert "Merge pull request #27550 from mtsmfm/fix-generator-command-for-nested-rails-engine"
という訳で直前でコミットされたrails engineのgeneratorの修正をrevertしています。
外部キー制約を無効にするのに、DISABLE TRIGGER ALLを使用するようになっていたのを、SET CONSTRAINTS ALL DEFERREDが使用出来る場合(9.4.2以上)の場合、そちらを使用するよう修正した、Merge pull request #21233 from mtsmfm/disable-referential-integrity-without-superuser-privilegesをrevertしています。テストがコケるようになってしまった為。
Fix find_by and where consistency
activerecord/lib/active_record/core.rbの修正です。
find_byとwhereでActive Recordのインスタンスを渡した場合の挙動が異なっていたのを、同じ結果を返すよう修正しています。
# before user = User.find_by(id: 1) # => #<User id: 1> User.where(id: user).first # => #<User id: 1> User.find_by(id: user) # => nil
# after user = User.find_by(id: 1) # => #<User id: 1> User.where(id: user).first # => #<User id: 1> User.find_by(id: user) # => #<User id: 1>
Rails 4.xでは同じ値が返るようになっていた為、挙動を合わせる為修正したようです。
Fix configuration test now that Metal#env was removed
railties/test/application/configuration_test.rbの修正です。
削除されたActionController::Metal#envメソッドを使用している箇所があったのを、request.envを使用するよう修正しています。
Rails.env falls back to dev mode when env var is empty
railties/lib/rails.rbの修正です。
元々はRAILS_ENVまたはRACK_ENVが環境変数が定義されていたら、値が空かどうかに関わらずその値を使用するようになっていたのを、値が空の場合は使用しないよう修正しています。
- @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development") + @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"].presence || ENV["RACK_ENV"].presence || "development")
Add instructions for available_locales [skip ci]
rails guideのRails Internationalization (I18n) APIの修正です。
initializerでdefault localeを設定する場合のexampleコードで、I18n.available_localesの設定が漏れていたのを修正しています。
Raise error when has_many through is defined before through association
activerecord/lib/active_record/associations.rb、
activerecord/lib/active_record/reflection.rbの修正です。
has_many through associationをthrough先のassociationより先に定義した場合、HasManyThroughOrderErrorをraiseするよう修正しています。
class Developers < ActiveRecord::Base has_many :companies, through: :contracts has_many :contracts, foreign_key: :developer_id end
上記のような順番でassociationを定義した場合にHasManyThroughOrderErrorがraiseされます(:contractsを先に定義すればOK)。元々エラーにはなっていたのですが、association定義が原因である事がわかりずらいエラーになっていた為、何が原因が明確にわかるエラーをraiseするよう修正したようです。