2017/01/04分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Respect precision option for arrays of timestamps.
- Raise
ArgumentError
when passing anActiveRecord::Base
instance to.find
,.exists?
and.update
. - Compare deserialized values for
PostgreSQL::OID::Hstore
types when callingActiveRecord::Dirty#changed_in_place?
- Remove deprecated db:test:clone* tasks
- Deprecate passing
name
toindexes
. - 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:configs
andrails:update:bin
. - Remove deprecated
CONTROLLER
environment variable forroutes
task. - Make
Rails.env
fall back todevelopment
whenRAILS_ENV
andRACK_ENV
is 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するよう修正したようです。