2020/05/18分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Add signed ids to Active Record (#39313)
- Add support for finding records based on signed ids, which are tamper-proof, verified ids that can be set to expire and scoped with a purpose. This is particularly useful for things like password reset or email verification, where you want the bearer of the signed id to be able to interact with the underlying record, but usually only within a certain time period.
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.rb
、
activerecord/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.md
、
railties/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.rb
、
activerecord/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.rb
、
activerecord/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の修正です。
where
にvalueの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
の修正です。
where
にvalueの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を使用してサジェスチョンを出すよう修正しています。