2014/07/16分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Calling
#empty?
on ahas_many
association would use the value from the counter cache if one exists. - Fix version detection for RENAME INDEX support. Fixes #15931.
- Restore 4.0 behavior for using serialize attributes with
JSON
as coder.
activemodel/CHANGELOG.md
- Deprecate ActiveModel::Dirty#reset_changes in favor of #clear_changes_information
- Deprecate
reset_#{attribute}
in favor ofrestore_#{attribute}
.
Merge pull request #15266 from dv/use_counter_cache_for_empty_call
activerecord/lib/active_record/associations/has_many_association.rb
の修正です。
HasManyAssociation#empty?
メソッドを追加して、counter cacheを使用している場合、counter cacheの値を使用するよう修正しています。
Add CHANGELOG entry for #15266
activerecord/CHANGELOG.md
の修正です。
上記empty?
メソッドの対応についてCHANGELOGに追記しています。
Fix version detection for RENAME INDEX support. Fixes #15931.
MySQLのConnectionAdapterの修正です。
MySQLの5.7からALTER TABLEにRENAME INDEXという書式が追加されたのですが、MariaDBでは対応していないので、MariaDBの場合RENAME INDEXを使用しないよう修正しています。
MariaDBだと使用出来ないんですねえ。何でだろう。
Revert "Revert "Merge pull request #16059 from jenncoop/json-serialized-attr""
revertのrevertで少しややこしいのですが、ActiveRecordの修正です。
serializeにJSONを指定した際の振る舞いを4.0系と同じ振る舞いに戻しています。
class Post < ActiveRecord::Base serialize :comment, JSON end class Comment include ActiveModel::Model attr_accessor :category, :text end post = Post.create! post.comment = Comment.new(category: "Animals", text: "This is a comment about squirrels.") post.save!
# 4.0 post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."} # 4.1 before post.comment # => "#<Comment:0x007f80ab48ff98>" # 4.1 after post.comment # => {"category"=>"Animals", "text"=>"This is a comment about squirrels."}
"4.1 before"同等の動作が必要な場合、こちらを参考に対応してとの事。
Predicate methods don't need to return true
/ false
MariaDBの判定処理を修正しています。
- !!(full_version =~ /mariadb/i) + full_version =~ /mariadb/i
不要なboolへの変換処理を削除しています。
Merge pull request #16162 from chancancode/fix_json_coder
activerecord/lib/active_record/coders/json.rb
の修正です。
self.load
メソッドで引数のjsonのnilチェックを追加しています。
DBのデータnilだった場合にExceptionが発生してしまうので対応しています。
Topic.serialize :content, JSON # Force a row to have a database NULL instead of a JSON "null" id = Topic.connection.insert "INSERT INTO topics (content) VALUES(NULL)" t = Topic.find(id) assert_nil t.content t.save! # On 4.0, re-saving a row with a database NULL will turn that into a JSON # "null" assert_equal 1, Topic.where('content = "null"').count
databaseのNULLとJSONの"null"が混ざってちょとややこしい…。
Fixed SQL syntax for postgresql
activerecord/test/cases/serialized_attribute_test.rb
の修正です。
PostgreSQLでSQL syntaxエラーが出ていたのを修正しています。
- assert_equal 1, Topic.where('content = "null"').count + assert_equal 1, Topic.where("content = 'null'").count
シングルクォートじゃないのが問題ですね。
Document the change in nil
handling for serialized attributes
ActiveRecordの各doc、testとupgrading_ruby_on_railsの修正です。
serialized attributesにnil
を指定した際に、'null'という文字列ではなく、DBのNULLとして値が格納される旨説明とテストを追加しています。
Add Rails::Application#config_for
railties/lib/rails/application.rb
の修正です。
設定ファイルロード用のRails::Application.config_for
メソッドを追加しています。
# config/exception_notification.yml: production: url: http://127.0.0.1:8080 namespace: my_app_production development: url: http://localhost:3001 namespace: my_app_development # config/production.rb MyApp::Application.configure do config.exception_notification = config_for(:exception_notification) end Rails.application.config.exception_notification['url'] # => http://127.0.0.1:8080
環境毎に異なる値を別ファイルで管理出来るの便利ですね。SettingsLogic使ってた箇所置き換えられるかも。関係無いですが、CHANGELOGに書いてあるサンプルおかしい気が…。
Deprecate ActiveModel::Dirty#reset_changes in favor of #clear_changes_information
activemodel/lib/active_model/dirty.rb
の修正です.
ActiveModel::Dirty#reset_changes
メソッドがdeprecateになりました。今後は、代わりにActiveModel::Dirty#clear_changes_information
を使用してとの事。
reset_#{attribute}
メソッドと名前がバッティングする為のようです。
Deprecate reporting methods for silencing output as they aren't thread safe
activesupport/lib/active_support/core_ext/kernel/reporting.rb
の修正です。
Kernelに追加されてた、silence_stderr
、capture
、quietly
がdeprecateになりました。threa safeじゃない為との事。
capture
は使用したので、対応しなきゃ。
Implement required #encode_with
activerecord/lib/active_record/relation/delegation.rb
の修正です。
encode_with
メソッドを追加しています。yaml_serialization_test.rb
のテスト実行時にwarningが出力されていて、その対応のようです。
Keep quietly and capture undeprecated on your suite
各テストの追加です。
silence_stderr
、capture
、quietly
がdeprecateになったのですが、テストで使用していうる箇所があったので、各テスト中で同名のメソッドを定義しています。
ああ、このやり方良いですねえ。
Add CHANGELOG entry for #13392 [ci skip]
上記メソッドのdeprecateについてCHANGELOGに追記しています。
Deprecate reset_#{attribute}
in favor of restore_#{attribute}
.
ActiveRecordの修正です。
reset_#{attribute}
メソッドがdeprecateになりました。今後は代わりにrestore_#{attribute}
を使うようにとの事です。あれ、reset_changesのdeprecateの理由が…。
RouteSet should be in charge of constructing the dispather
Routingの修正です。
Mapper::Mapping
クラスのコンストラクタにRouteSet
を追加しています。
actionpack/test/controller/routing_test.rb
の修正です。
使用していない変数を削除しています。
actionpack/test/controller/routing_test.rb
の修正です。
setup
メソッドでset
処理行うよう修正しています。
execute a request and check the path_parameters
actionpack/test/controller/routing_test.rb
の修正です。
requestの実行と、path_parameters
のチェック処理を追加しています。 実際本番で使われるの近い形でテストする為に、のようです。
stop calling url_for with recall parameters and actually use a request
routingのテストの修正です。
url_for
メソッドを使用するのではなう、requestを使用するようテストを修正しています。
actionpack/test/abstract_unit.rb
の修正です。
使用してない変数を削除しています。
rack 1.6 encodes the filenames in posts correctly now
actionpack/lib/action_dispatch/http/upload.rb
の修正です。
rack1.6ではpost処理でファイルネームが正しくエンコードされるようになったらしく、独自でencodeを行っていた処理を削除しています。
Move uuid_v5 and uuid_v3 to Digest::UUID
Digest::UUID
モジュールの追加です。
uuid_v3
、uuid_v5
メソッドをSecureRandom
からDigest::UUID
モジュールに移動しています。
Digest::UUID
配下にあるのが適切だろう、という事で移動しています。
stop passing recall to url_for
actionpack/test/controller/url_for_integration_test.rb
の修正です。
テスト内でurl_for
メソッドにrecall
オプションを渡すのを止めています。むう、これは何でだろう。
activerecord/lib/active_record/relation.rb
の修正です。
Delegation
配下にあった#encode_with
メソッドをRelation
に移動しています。
routed applications will respond to these methods
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
define_generate_prefix
の中で、行っていたrespond_to?(:define_mounted_helper)
を削除しています。
routed applicationでは定義されているから、とコミットログにはあるのですが、いや、エラーになるケースがあるよーとコメントされているので、戻されるかもですね。
actionpack/test/abstract_unit.rb
の修正です。
request_path_params
メソッドでキーワード引数を使用しているのですが、当然1.9系では動かないので修正しています。が、修正ミスが。
Fix 1.9. uggghhhhhh get it together @tenderlove :bomb:
再度actionpack/test/abstract_unit.rb
の修正です。
修正ミスの対応です。というか、間違ってコミットしたのかなあと。
Merge pull request #16138 from sgrif/sg-attribute-set-key
activerecord/lib/active_record/attribute_set.rb
の修正です。
AttributeSet#include?
-> AttributeSet#key?
に名前を変更しています。
より適切な名前に修正、ということのようです。
use foreign key DSL in our tests.
activerecord/test/cases/adapters/mysql2/schema_migrations_test.rb
の修正です。
生のSQLで外部キー設定していた箇所を、add_foreign_key
メソッドを使うよう修正しています。
document assert[not]empty, assert[not]includes, assert[not]predicate in testing guide.
rails guideのA Guide to Testing Rails Applications
の修正です。
assert_empty、assert_not_empty、assert_includes、assert_not_includes、assert_predicate、assert_not_predicateメソッドについて追記しています。
link minitest assertions documentation.
rails guideのA Guide to Testing Rails Applications
の修正です。
minitest assertions へのリンクを追加しています。
Active Record tests still depend on capture
. Let's keep it for now.
activerecord/test/cases/test_case.rb
の修正です。
UndeprecateCapture
モジュールを作成して、capture
メソッドをUndeprecateCapture
モジュール配下に移動しています。
capture
メソッドに依存しているテストが多かったらしく、test_caseのでメソッド読み込むように対応しています。
we intend to keep the capture
helper for Active Record tests.
activerecord/test/cases/test_case.rb
の修正です。
UndeprecateCapture
モジュールは止めて、TestCase
クラスの下にcapture
メソッドを追加するよう修正しています。