なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2017/06/17)

2017/06/17分のコミットです。

CHANGELOGへの追加はありませんでした。


Merge pull request #29140 from notEthan/log_subscribed_avoid_rescuing

activesupport/lib/active_support/log_subscriber.rbの修正です。

LogSubscriber::finishメソッドでloggerを使用する前にloggerインスタンスが生成されているかチェックするよう修正しています。


Add the <app_root>/test dir to the $LOAD_PATH as a string:

railties/lib/rails/commands/test/test_command.rbの修正です。

$LOAD_PATHにtest directoryがPathnameのobjectとして追加されていたのを、Stringとして追加するよう修正しています。 Rails 5.0まではStringとして追加されており、挙動を合わせる為との事です。


Remove references to deprecared raise_runtime_errors from documentation, which is always enabled now. Ref: https://github.com/rails/sprockets-rails/commit/655b93bffc6f51b96a7cc097f9010942693bfaae and https://github.com/rails/rails/pull/24070 . Fixes #29483 [ci skip] (#29484)

rails guideのThe Asset PipelineConfiguring Rails Applicationsの修正です。

deprecaredになっていたconfig.assets.raise_runtime_errorsについての説明を削除しています。


Merge pull request #29470 from kamipo/use_nullable_column_instead_of_primary_key

activerecord/test/schema/schema.rbの修正です。

subscribers tableでprimary keyとしてidを使用していたのを、普通のカラムとしてidを定義するよう修正しています。

-  create_table :subscribers, force: true do |t|
+  create_table :subscribers, id: false, force: true do |t|
     t.string :nick, null: false
     t.string :name
+    t.integer :id

idカラムをINSERTの際に使用しないテストで使われているのですが、oracle-enhanced adapterだとエラーになってしまう(ActiveRecord::NotNullViolation: OCIError: ORA-01400がおきてしまう)為、primary keyではなくnullを指定可能な通常のカラムとして定義するようにしたようです。


Merge pull request #29461 from dnl/unscope_where_or

activerecord/lib/active_record/relation/query_methods.rbの修正です。

orメソッドに指定するRelationでunscopeを使用したい場合、両方のRelationにorが無いとエラーになってしまっていたのを、エラーにならないよう修正しています。

# before
partial = Post.where("id = 1 and id != 2")
partial.or(partial.unscope(:where).where("id = 2"))
# => ArgumentError: Relation passed to #or must be structurally compatible. Incompatible values: [:unscope]

# after
partial = Post.where("id = 1 and id != 2")
partial.or(partial.unscope(:where).where("id = 2"))
# => Post.where("id = 1 or id = 2")

Merge pull request #29431 from kamipo/fix_create_table_with_query_from_relation

activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rbの修正です。

schema生成時に、RealtionからQueryを生成する、かつ、Relationでbindを使用している場合に、不正なSQL(値のbindが行われない)が生成されてしまうバグがあったのを修正しています。


Merge pull request #29392 from alexcameron89/unpersisted_create_association

activerecord/lib/active_record/associations/singular_association.rbの修正です。

parentがsaveされてない状態でsingular associationのcreate処理を呼び出した場合に、エラー(ActiveRecord::RecordNotSaved)をraiseするよう修正しています。

firm = Firm.new
firm.create_account
# => ActiveRecord::RecordNotSaved

Remove FK together with column in MySQL

activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rbの修正です。

MySQL adapterのremove_columnメソッドで、カラムを削除する際に外部キー制約も合わせて削除するよう修正しています。


Merge pull request #29415 from kamipo/remove_unused_defined_association

activerecord/test/models/comment.rbの修正です。

Commentクラスから使用していないdeveloper assocationを削除しています。


[ci skip] Update fedora SQLite3 package name

rails guideのDevelopment Dependencies Installの修正です。

Set up and Run the Testsの項、sqlite3のパッケージ名を修正しています。