rsim/oracle-enhanced — pull request #169 by jeffperrin (2012-05-16 21:47:20+00:00)
Title: Add a :schema option to allow switching the active schema using 'alter session'

Makes a schema option available in database.yml like so:

development:
database: xe
username: database_user
password: 1234
adapter: oracle_enhanced
host: localhost
schema: schema_to_use

Use case:

I work in a corporate environment that insists on running the application under a different user/schema than the schema where the application lives (ie; blah_update_user is what we connect with, but the app lives in the blah schema). We could hack around this in Rails by hard-coding schema prefixes in a `set_table_name` declaration, but this had many implications including making setup of testing databases extremely annoying.

This patch basically just runs `alter session set current_schema = schema_name` immediately after initializing a connection. We've been using a variation of this patch in several production jruby/rails3/oracle 10/11 applications for the past year without issue.