Oracle tablespaces

Rick B. wrote:

This works, and the synonym person is only visible to user b
Our DBAs set up a development schema, a production schema, and N testing
schemas (1 for each developer, one for nightly demo builds, one for
continuous integration builds). I’m not a DBA so perhaps I’m missing a
salient detail, but after removing the troublesome synonyms we haven’t
had any problems in this configuration.

I’m not saying it doesn’t work when it’s all set up properly.

In my case, I needed to write a new Rails script using script/runner and
didn’t
want to have the DBA make changes for the app, as the less work he did,
the
better for me and getting Rails used.

For the new app, they set up a new user ‘svn2its’, which didn’t have
‘its’ as
its default schema and is also not the owner.

So anything in Rails to make this case easier to work with (no synonyms,
no
default schema, no ownership) would be great.

Maybe that’s asking for too much :slight_smile: But using the

class Issue < ActiveRecord::Base
connection.execute(‘alter session set current_schema=its’)
end

trick did work. Although, this may not work if you have Rails working
with more
than one schema. In this case, I think the easiest way to do this is to
introduce an intermediate class and have the final model subclass it:

class OracleSchemaA < ActiveRecord::Base
establish_connection
connection.execute(‘alter session set current_schema=SCHEMAA’)
end

class OracleSchemaB < ActiveRecord::Base
establish_connection
connection.execute(‘alter session set current_schema=SCHEMAB’)
end

class Post < OracleSchemaA
set_table_name ‘post’
end

class Author < OracleSchemaB
set_table_name ‘author’
end

There are two classes that explicitly create separate connections to the
database, each with its own current_schema.

The set_table_names are required, otherwise AR seems to want to use
oracleschemaX as the table name.

Regards,
Blair

Michael Schoen wrote:

Note the double appearance of its in the WHERE clause.

What revision of Rails are you using? I just confirmed again that with
edge rails this works properly.

I just retried with Rails edge (with ‘rake freeze_edge’), now at
revision 3166.

Regards,
Blair

What revision of Rails are you using? I just confirmed again that with
edge rails this works properly.

I just retried with Rails edge (with ‘rake freeze_edge’), now at
revision 3166.

And? Did you get the same error? Edge is currently 3173, though I don’t
see any changes since 3166 that should matter.

I’m going offline for a bit. If this still isn’t working let me know and
let’s take it off the list – I’d like to send you some debug statements
to apply that may help identify the issue.

Note the double appearance of its in the WHERE clause.

What revision of Rails are you using? I just confirmed again that with
edge rails this works properly.

Michael Schoen wrote:

What revision of Rails are you using? I just confirmed again that
with edge rails this works properly.

I just retried with Rails edge (with ‘rake freeze_edge’), now at
revision 3166.

And? Did you get the same error? Edge is currently 3173, though I don’t
see any changes since 3166 that should matter.

Yes, same error, even with r3174.

I’m going offline for a bit. If this still isn’t working let me know and
let’s take it off the list – I’d like to send you some debug statements
to apply that may help identify the issue.

OK. Send me the debug statements privately and I’ll test them out.

It would be interesting to see if you can find a similar select
statement in
your rails application and see what queries its doing.

Regards,
Blair

OK. Send me the debug statements privately and I’ll test them out.

It would be interesting to see if you can find a similar select
statement in your rails application and see what queries its doing.

That’s what I tried – I created what I think is an exact replica or
your scenario, and it worked properly – the schema name was not
duplicated.