backport runner fixes to 3-2-stable

Add a runner hook to Rails::Application and Rails::Engine that requires
ActiveRecord::Base to avoid circular constant loading when using observers.

This commit backports cc7dd66, c0ba0f0 and 8d01c61.
adding test for CVE
Allow failures to 2.0.0
don't cache invalid subsets when preloading hmt associations.

Backport #9252.

Conflicts:

	activerecord/CHANGELOG.md
	activerecord/test/cases/associations/eager_test.rb

The preloader code on 3-2-stable is not based on relations but on option hashes.
I had to modify the original patch and comparing the option hashes could be more
fuzzy than comparing the relations. All the tests passed though.
Merge pull request #9322 from senny/backport_9252

don't cache invalid subsets when preloading hmt associations.
keep the build :green_heart:, #first on 1.8.7 and pg is different

The build only failed for ruby-1.8.7 and pg. The problem was that the statement:

```ruby
author = Author.includes(:comments_with_order_and_conditions, :posts).first
```

resulted in Author with ID 2 where on all other rubies / db-engines Author with ID 1
was retunred. Of course this breaks the assertions.
Merge pull request #9323 from senny/build_fix_from_9252

keep the build :green_heart:, #first on 1.8.7 and pg is different
Use order to get the first record since postgresql returns in the
desired order
Change tabs to spaces in form options helper [ci skip]
determine the match shorthand target early.

Backport #9361.
Closes #7554.

This patch determines the `controller#action` directly
in the `match` method when the shorthand syntax is used.
this prevents problems with namespaces and scopes.
Merge pull request #9374 from senny/improved_match_shorthand_syntax

determine the match shorthand target early.
Use 1.8 hash style
Sqlite preserves primary keys when copying/altering tables.

Backport #2312.
Fixes #9367.

I also added a test-case to make sure that renaming or removing
a column preserves the primary key.
Merge pull request #9388 from senny/9367_wrong_schema_after_remove_column

Sqlite preserves primary keys when copying/altering tables.
Add in missing requires
`name` should be public.
Fix failing test case when no database.yml
Define #inspect instead of #to_s

Ruby 2.0 Object#inspect does not call #to_s by default anymore.
search private and protected methods for convert_key
Ruby 2.0.0 defaults source encoding to utf-8 so we need to specifically tag this file with us-ascii