なるようになるブログ

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

rails commit log流し読み(2014/12/27)

2014/12/27分のコミットです。

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


Update guides regarding the extension changes

Rails Guideの修正です。

coffee、scssのexampleからそれぞれjs、css拡張子を削除しています。

以前にも書きましたが、それぞれ、coffee-railssass-railsの変更による影響です。


Correctly ignore case_sensitive for UUID uniqueness validation

ActiveRecordのConnectionAdaptersの修正です。

UUID型のカラムにuniqueness validation + case_sensitiveオプションを設定した場合に、case_sensitiveの設定を無視するよう対応しています。

本来、UUID型はデフォルトでcase insensitive なので、case_sensitiveのオプションを設定するのはそもそも不要そうなのですが、4.1系の挙動に合わせる為、動作するよう修正したようです。


Propagate frozen state during transaction changes

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

transactions処理中に、frozen状態の管理に誤りがあり、Rollback時に"Can't modify frozen hash"エラーが発生するケースがあったのを対応しています。

テストコードより。

topic = Topic.create
reply = topic.replies.create

Topic.transaction do
  topic.destroy # calls #destroy on reply (since dependent: destroy)
  reply.destroy

  raise ActiveRecord::Rollback   #=> ここで "Can't modify frozen hash"が起きてしまっていた
end

Remove unused @relation instance variable

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

使用していない@relation変数を削除しています。


Inject the PredicateBuilder into the Relation instance

ActiveRecordの修正です。

Relationクラスのコンストラクタにの引数に PredicateBuilderを追加しています。

PredicateBuilderの生成処理を一度に済ませる為の、リファクタリング、ですかねえ…。


Add missing :nodoc:

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

:nodoc:を追加しています。


Change PredicateBuilder handler methods to instance methods https://github.com/rails/rails/commit/a3936bbe21f4bff8247f890cacfd0fc882921003

ActiveRecordの修正です。

PredicateBuilderのhanlder用のクラスを新規に作成し、handle処理をそちらのクラスで行うよう修正しています。


Re-use the predicate builder in the ArrayHandler

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

ArrayHandlerコンストラクタの引数にPredicateBuilderクラスを渡せるようにし、PredicateBuilderを使いまわせるよう修正しています。


Refactor association handling in PredicateBuilder

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

expandの中で行っていたassociationに関するQueryの生成処理を、 新規に作成したPredicateBuilder::AssociationQueryHandlerPredicateBuilder::AssociationQueryValueクラスで行うようリファクタリングしています。


Fix new warning in ruby 2.2

activerecord/test/cases/relation/mutation_test.rbの修正です。

relation -> @relationに修正しています。

Ruby 2.2でwarningが出たのでその対応との事です。何のwarningだろう。


Remove klass and arel_table as a dependency of PredicateBuilder

ActiveRecordの修正です。

PredicateBuilderクラスから、klassarel_tableを削除しています。代わりに、メタ情報を保持する為のTableMetadataクラスを新規に作成し、そちらで必要な情報保持するよう修正しています。


Perform casting of single values within the predicate builder

ActiveRecordの修正です。

単一値のキャスト処理をpredicate builderの中で行うよう修正しています。


Eagerly cast range values in the predicate builder

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

PredicateBuilderの中でcastした値を取得するよう修正しています。

Arel側の変更に合わせて修正しているようです。


Eagerly cast array values passed to the predicate builder

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

今度はPredicateBuilderArrayHandlerでcastした値を取得するよう修正しています。

Arelからtype cast処理を削除する為のリファクタリングのいっかんとの事です。


Go through normal where logic when preloading associations

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

associationをpreloading済みの場合に生成されるSQLを"in"から"="に修正しています。

Developer.where(:id => 1).includes(:audit_logs).explain

# before
EXPLAIN for: SELECT `audit_logs`.* FROM `audit_logs` WHERE `audit_logs`.`developer_id` IN (1)

# after
EXPLAIN for: SELECT `audit_logs`.* FROM `audit_logs` WHERE `audit_logs`.`developer_id` = 1)

We don't need to perform type casting on the STI condition

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

type_conditionメソッドArel::Nodes::Quotedの値のラップ処理を追加しています。

Arelからtype cast処理を削除する為のリファクタリングのいっかんですかねえ。

因みに、このそのラップ処理もRails 5.1で削除予定との事。


We don't need to cast the value a second time in uniqueness validations

activerecord/lib/active_record/validations/uniqueness.rbの修正です。

build_relationメソッドArel::Nodes::Quotedでの値のラップ処理を追加しています。

Arelからtype cast処理を削除する為のリファクタリングの一環。


Go through normal where logic in uniqueness validation

activerecord/lib/active_record/validations/uniqueness.rbの修正です。

Arelのtableを使っている箇所をメソッドを使用するよう修正したり、諸々細かい箇所のリファクタリングを行っています。


Fall back to type casting from the connection adapter

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

TableMetadata::ConnectionAdapterTableクラスを作成し、 connection adapterから取得した値のcast処理をそのちらのクラスで行うよう修正しています。


We don't need to type cast the offset in find_in_batches

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

Arel::Nodes::Quotedでの値のラップ処理を追加しています。


Inform Arel that we don't need to cast a value in tests

activerecord/test/cases/scoping/default_scoping_test.rbの修正です。

Arelのメソッドを呼び出してテストを行っている箇所に、Arel::Nodes::Quotedでの値のラップ処理を追加しています。


Go through normal where logic in apply_join_dependency

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

Arel::Tableを使用している箇所を、使用しない形に修正しています。


Inform Arel that we don't need type casting in tests

activerecord/test/cases/relation_test.rbの修正です。

Arelのメソッドを呼び出してテストを行っている箇所に、Arel::Nodes::Quotedでの値のラップ処理を追加しています。


We don't need additional type casting for locking updates

activerecord/lib/active_record/locking/optimistic.rbの修正です。

Arel::Nodes::Quotedでの値のラップ処理を追加しています。


Go through normal update_all logic when updating counter caches

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

Arel::Tableを使用している箇所を、使用しない形に修正しています。


Go through normal update_all logic when updating lock columns

activerecord/lib/active_record/locking/optimistic.rbの修正です。

_update_recordメソッドArel::Tableを使用して処理を行っていたのを、update_allを使用するようリファクタリングしています。


Inform Arel that we don't need additional type casting in batching

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

find_in_batchesメソッドArel::Nodes::Quotedでの値のラップ処理を追加しています。


Inform Arel we don't need additional type casting in batches

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

find_eachメソッドArel::Nodes::Quotedでの値のラップ処理を追加しています。


Inform Arel we don't need additional type casting in tests

activerecord/test/cases/relation/merging_test.rbactiverecord/test/cases/relation/where_chain_test.rbactiverecord/test/models/author.rbの修正です。

Arelのメソッドを呼び出してテストを行っている箇所に、Arel::Nodes::Quotedでの値のラップ処理を追加しています。


Refactor PostgreSQL::TableDefinition#primary_key

activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rbの修正です。

primary_keyメソッドリファクタリングを行っています。


Add a note about non-buffering servers for AC::Live

rails guideのAction Controller Overviewの修正です。

Live Streaming of Arbitrary Dataの項に、WEBrickではActionController::Liveが使えない旨と、ActionController::Liveが使用出来るバッファリングしないAPサーバ(Puma/Rainbows等)についての情報を追記しています。