Inconsistencies when eager loading with fully-qualified table names using Oracle

This pull request adds a test demonstrating how table names are not correctly detected by ActiveRecord::Relation.  I've sketched out an insufficient patch (b039f1b3f781cd60a9c60d469c7fff1b744f9cb0) which allows the new test to pass for Oracle but breaks the test suite in other places, especially for other databases (or at least SQLite3).

In order to get the test to fail, run 'rake test_oracle' after setting up test/config.yml to use an Oracle database with a username like 'ops$user', or any valid variation that has non-word characters in it.  It should pass otherwise.

Discussion
------------------------

Eager loading will revert to the left-outer-join strategy when using fully-qualified table names on Oracle. For example:

```ruby
  class Dept < ActiveRecord::Base
    set_table_name "dept"
  end
  
  class Emp < ActiveRecord::Base
    set_table_name "emp"
    belongs_to :dept, :select => "id, name nombre"
  end
  
  Emp.find(1, :include => :dept).dept.nombre       # ok
  Emp.find(:first, :include => :dept).dept.nombre  # ok
```

This code works as written because the default one-query-per-association strategy is used; as a result the select is used and nombre gets set on the dept record. However if you qualify the table name then the select is not used in some cases; find using an id breaks but find :first still works.

```ruby
  class Dept < ActiveRecord::Base
    set_table_name "schema_name.dept"
  end
  
  class Emp < ActiveRecord::Base
    set_table_name "schema_name.emp"
    belongs_to :dept, :select => "id, name nombre"
  end
  
  Emp.find(1, :include => :dept).dept.nombre       # NoMethodError
  Emp.find(:first, :include => :dept).dept.nombre  # ok
```

In the id case eager loading reverts to the left-outer-join strategy and the select is ignored. The difference can be traced to the `tables_in_string` method which is responsible for extracting tables from the select string. This is how it's written in 2.3.5:

```ruby
  # [active_record/association.rb]
  def tables_in_string(string)
    return [] if string.blank?
    string.scan(/([\.a-zA-Z_]+).?\./).flatten
  end
```

Turns out the regexp doesn't handle the fully-qualified names properly. There were [some patches](https://rails.lighthouseapp.com/projects/8994/tickets/4770-patch-patches-for-activerecord-oracle-enhanced-adapter-compatibility) that partially fix this in 3.0.0 but the fix isn't complete. This is how the same method is currently:

```ruby
  # [active_record/relation.rb]
  def tables_in_string(string)
    return [] if string.blank?
    # always convert table names to downcase as in Oracle quoted table names are in uppercase
    # ignore raw_sql_ that is used by Oracle adapter as alias for limit/offset subqueries
    string.scan(/([a-zA-Z_][.\w]+).?\./).flatten.map{ |s| s.downcase }.uniq - ['raw_sql_']
  end
```

This handles word-based schemas, but it will not handle other valid Oracle schemas like 'schema$name' nor will it handle tables with a db link. The method can be kind-of fixed with a fancier regexp:

```ruby
  class ActiveRecord::Relation
    NONQUOTED_OBJECT_NAME   = /[A-Za-z][A-z0-9$#]{0,29}/
    NONQUOTED_DATABASE_LINK = /[A-Za-z][A-z0-9$#\.@]{0,127}/
    TABLES_IN_STRING = /((?:#{NONQUOTED_OBJECT_NAME}\.)?#{NONQUOTED_OBJECT_NAME}(?:@#{NONQUOTED_DATABASE_LINK})?)\..?/
  
    def tables_in_string(string)
      return [] if string.blank?
      string.scan(TABLES_IN_STRING).flatten.map {|str| str.downcase }.uniq - ['raw_sql_']
    end
  end
  
  class Dept < ActiveRecord::Base
    set_table_name "schema_name.dept"
  end
  
  class Emp < ActiveRecord::Base
    set_table_name "schema_name.emp"
    belongs_to :dept, :select => "id, name nombre"
  end
  
  Emp.find(1, :include => :dept).dept.nombre       # ok
  Emp.find(:first, :include => :dept).dept.nombre  # ok
```

But this is getting kinda wild. Moreover it's not correct for other databases.

A couple links:

* [a test of the regexp above](https://gist.github.com/490817)
* [a more thorough study of the select issue](https://gist.github.com/486750)

And note that this reproduces and addresses [issue 5200](https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5200-inconsistencies-when-eager-loading-with-fully-qualified-table-names-using-oracle) from lighthouse, which was not migrated to github.