2015/09/08分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activemodel/CHANGELOG.md
Merge pull request #20534 from qnm/activesupport-require-issue
activesupport/lib/active_support/core_ext/time/calculations.rb
の修正です。
active_support/core_ext/date/calculations
のrequireが不足していたのを追加しています。
activerecord/test/models/face.rb
のdocの修正です。
length
を lengh
にタイポしていたのを修正しています。
Correct query for PostgreSQL 8.2
activerecord/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb
の修正です。
query_conditions_for_initial_load
メソッドでtype name取得する際、generic castを使用していたのですが、この機能が追加されたのがPostgreSQL 8.3なので、8.2より以前でも動作するよう、
regprocedureを使用して書きなおしています。
- OR t.typinput::varchar = 'array_in' + OR t.typinput = 'array_in(cstring,oid,integer)'::regprocedure
Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once
Active Model / Active Recordの修正です。
valid?
/ invalid?
メソッドに複数のコンテキストを渡せるよう修正しています。
class Person include ActiveModel::Validations attr_reader :name, :title validates_presence_of :name, on: :create validates_presence_of :title, on: :update end person = Person.new person.valid?([:create, :update]) # => false person.errors.messages # => {:name=>["can't be blank"], :title=>["can't be blank"]}
便利そう。 が、直ぐさまrevertされています。
Revert "Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once"
という訳で、先のvalid?
/ invalid?
メソッドに複数のコンテキストを渡せるよう修正したコミットをrevertしています。
revert理由は、"Active Recordのテストが壊れた為"となっていました。後ほど、テストを修正した状態で再度マージされています。
Merge pull request #21534 from Vratislav/clarify-custom-config-guide
rails guideのConfiguring Rails Applications
の修正です。
Custom configuration
の項、 custom configurationについて説明している箇所に、値はconfig.x
プロパティ配下に設定される旨説明を追加しています。
Use Hash[] instead of Hash#dup in resolve_column_aliases
activerecord/lib/active_record/table_metadata.rb
の修正です。
resolve_column_aliases
メソッドで、Hashの複製に。Hash#dup
を使用していたのを、代わりにHash#[]
を使用するよう修正しています。
Hash#dup
はパフォーマンスに問題がある為、との事です。詳細は、 Bug #7166: Speed up Hash#dup by patching Hash#initialize_copy - Ruby trunk - Ruby Issue Tracking System 参照。
Validate multiple contexts on valid?
and invalid?
at once.
Active Model / Active Recordの修正です。
valid?
/ invalid?
メソッドの対応を、再度コミットしています。
.gitignore: Ignore .ruby-version in any subdir
.gitignore
の修正です。
/.ruby-version
のみignoreの対象にしていたのを、ディレクトリを指定せず、ファイル名のみでチェック(.rub-version
)するよう修正しています。
Support mysql2 0.4.0, first release with prepared statements support
Gemfile
、activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
の修正です。
仕様するmysql2
gemのバージョンを0.4.0
以上に修正しています。
プリペアドステートメントを使用する為のようですねえ。
Make config.force_ssl
less dangerous to try and easier to disable
actionpack/lib/action_dispatch/middleware/ssl.rb
の修正です。
config.force_ssl
オプションの扱いについての改善対応を行っています。
SSL redirect:
* :host
、:port
オプションをredirect
パラメータ内に移動
* :status
、:body
をカスタマイズ出来るよう対応。301だとブラウザがキャッシュしてしまい、テストの際に使いづらいので、テストの際に302、307が使用出来るよう対応したようです。
HTTP Strict Transport Security (HSTS):
* max-ageのデフォルトを1年から180に変更。
* hsts: false
を指定した場合、hstsを無効化出来るよう、hsts: { expires: 0 }
を送信するよう修正。
* preload: true
オプションを指定した場合、ブラウザのpreload listにサイトを追加するよう送信します(Preloaded HSTSを使用)。
HSTSのpreloadの仕組みとか初めてしりました。詳細は、Ssl - HSTS (HTTP Strict Transport Security) の導入 - Qiitaをご参照。
Reduce allocation in resolve_column_aliases
.
activerecord/lib/active_record/table_metadata.rb
の修正です。
TableMetadata#resolve_column_aliases
メソッドで、不要なアロケーションが行われないようにする為に、
Hash#keys
+ Array#grep
していたのを、Hash#each
だけでループ回すりょうリファクタリングしています。性能改善対応。
activerecord/lib/active_record/reflection.rb
の修正です。
reflections accessorの値をメモ化するよう修正しています。
reflectionsの値は、add_reflection
メソッドを呼び出したりしない限り、クラスロード時から値が変わる事は無いため、一度作成した値を使いまわすよう修正したとの事です。
activerecord/lib/active_record/reflection.rb
の修正です。
先の修正で、変数名をタイポしてしまっていた箇所があったのを修正しています。
Merge pull request #21519 from y-yagi/test_runner_raise_error
railties/lib/rails/test_unit/minitest_plugin.rb
、
railties/lib/rails/test_unit/test_requirer.rb
の修正です。
rails test
コマンドに存在しないファイルやディレクトリを指定した場合に、エラーになるよう修正しています。
Replace AR with ActiveRecord to make it more readable [ci skip]
各docの修正です。
Active Recordを、略語のARと記載していた箇所を、正式名称(Active Record)で記載するよう修正しています。
activerecord/test/cases/view_test.rb
の修正です。
MySQL adapterで、viewのテストがなかったので、テストを追加しています。
Define SchemaStatements#tables
as interface
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
の修正です。
SchemaStatements#tables
メソッドを定義しています。
実際のメソッドの実装は各adapter配下でそれぞれ行っているので、インターフェースのみです(NotImplementedError
をraiseするだけ)。
Merge pull request #21511 from rwz/ar-exceptions-no-args
Active Recordの修正です。
Active Record配下のエラークラスは、元々は引数が全て必須パラメータだったのですが、実際は使用しない引数もある為、 引数にデフォルト値を設定し、必須ではなくなるよう修正しています。
例。
class HasManyThroughAssociationNotFoundError < ActiveRecordError #:nodoc: - def initialize(owner_class_name, reflection) - super("Could not find the association #{reflection.options[:through].inspect} in model #{owner_class_name}") + def initialize(owner_class_name = nil, reflection = nil) + if owner_class_name && reflection + super("Could not find the association #{reflection.options[:through].inspect} in model #{owner_class_name}") + else + super("Could not find the association.") + end end end