なるようになるブログ

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

rails commit log流し読み(2020/05/18)

2020/05/18分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Add default ENV variable option with BACKTRACE to turn off backtrace cleaning (#39220)

railties/lib/rails/generators/rails/app/templates/config/initializers/backtrace_silencers.rb.ttの修正です。

BACKTRACE envを指定している場合、backtrace cleaningをoffにするよう修正しています。Rails自体のデバッグをするときよう。なお、config/initializers/backtrace_silencers.rbで対応が行われている(ライブラリ側のコード修正は無い)為、使用するにはconfig/initializers/backtrace_silencers.rbを更新する必要があります。


Create update yarn task (#39314)

Action Text、railtiesの修正です。

bin/yarn stubを作成する為のapp:binstub:yarn taskを追加し、Action Textのインストーラでそのtaskを追加するよう修正しています。

元々はapp:update:binで経由でbin/yarn stubを作成していたのですが、不要なbin stubの更新処理も発生してしまい、それを避ける為。


Clear @_defer_touch_attrs when it has used

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

@_defer_touch_attrsの処理後の初期化が漏れていたのを追加しています。


Add signed ids to Active Record (#39313)

Active Recordの修正です。

signed idsを使用してrecordを取得する為の機能を追加しています。signed idはexpire time、purposeを指定する事が出来、purposeは不一致、または、expire timeを超えていた場合、idが一致してもデータが取得出来ないようになっています。

signed idsからレコードを取得する為のメソッドはfind_signed / find_signed!の2つあり、レコードが取得出来なかった場合に、 それぞれnilが返る / exception(ActiveSupport::MessageVerifier::InvalidSignature)をraise、というような挙動になっています。

signed_id = User.first.signed_id expires_in: 15.minutes, purpose: :password_reset

User.find_signed signed_id # => nil, since the purpose does not match

travel 16.minutes
User.find_signed signed_id, purpose: :password_reset # => nil, since the signed id has expired

travel_back
User.find_signed signed_id, purpose: :password_reset # => User.first
User.find_signed! "bad data" # => ActiveSupport::MessageVerifier::InvalidSignature

Remove redundant looking type up from explicit klass.attribute_types

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

typeの取得処理から不要なklass.attribute_typesからの取得処理を削除しています。


Use DidYouMean for AssociationNotFoundError

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

ActiveRecord::AssociationNotFoundErrorエラーが発生した場合に、did_you_meanを使用してサジェスチョンを出すよう修正しています。


Avoid allocating extra hash and arrays when as_json is called without options

activemodel/lib/active_model/serialization.rbactiverecord/lib/active_record/serialization.rbの修正です。

serializable_hashメソッドでoptionsが指定されていない場合不要なHash / Arrayのオブジェクトを生成しないよう修正しています。


Skip interpolated strings in AV::Digestor

actionview/lib/action_view/digestor.rbの修正です。

ActionView::Digestorでinterpolated stringは無視するよう修正しています。

interpolated stringを使用した場合に、template名に.を使用した場合のdeprecate warningが誤って出力されてしまうのを避ける為。


:scissors: trailing spaces [ci skip]

activerecord/CHANGELOG.mdrailties/CHANGELOG.mdの修正です。

ファイルからtrailing spacesを削除しています。


Use symbol consistently for operator in InfixOperation

activerecord/lib/arel/nodes/infix_operation.rbの修正です。

InfixOperationでoperatorの指定に全てSymbolを使用するよう修正しています。


Do not need explicit handler for InfixOperation's subclasses

activerecord/lib/arel/visitors/postgresql.rbactiverecord/lib/arel/visitors/to_sql.rbの修正です。

InfixOperationのサブクラスで不要な明示的なhandlerの指定を削除しています。


Fix update with dirty locking column to not match latest object accidentally

activemodel/lib/active_model/attribute.rbactiverecord/lib/active_record/locking/optimistic.rbの修正です。

locking columnを明示的に更新する際に、誤ってstable objectを更新してしまう可能性があったのを修正していmさう。


Fix rename column in bulk alter table for PostgreSQL

Active Recordの修正です。

PostgreSQL adapterでbulk alter table内のrename columnがエラーになってしまうバグがあったのを修正しています。


Support merging option :rewhere to allow mergee side condition to be replaced exactly

Active Recordの修正です。

mergeでmergeする条件を明示的に指定する為のrewhereオプションを追加しています。

david_and_mary = Author.where(id: david.id..mary.id)

# both conflict conditions exists
david_and_mary.merge(Author.where(id: bob)) # => []

# mergee side condition is replaced by rewhere
david_and_mary.merge(Author.rewhere(id: bob)) # => [bob]

# mergee side condition is replaced by rewhere option
david_and_mary.merge(Author.where(id: bob), rewhere: true) # => [bob]

Merge pull request #39219 from kamipo/bind_param

Active Recordの修正です。

wherevalueのArrayを指定した場合の性能改善対応(Merge branch 'fix-array-builder-wheres')により、prepared_statements: trueを指定している場合に、実行するSQLにbindが使われない、というリグレッションが発生していたのを修正しています。


Fix merging NOT IN clause to behave the same as before

activerecord/lib/arel/nodes/homogeneous_in.rbの修正です。

wherevalueのArrayを指定した場合の性能改善対応(Merge branch 'fix-array-builder-wheres')により、NOT INをmergeした際の挙動が変わってしまっていたのを、元の挙動になるよう修正しています。


Use DidYouMean for ActionNotFound

actionpack/lib/abstract_controller/base.rbの修正です。

AbstractController::ActionNotFoundエラーが発生した場合に、did_you_meanを使用してサジェスチョンを出すよう修正しています。