How to make Rose not use schema names in queries

18 views
Skip to first unread message

Matt Forsythe

unread,
Jan 18, 2012, 3:47:03 PM1/18/12
to Rose::DB::Object
Does anyone know how to tell Rose to leave off the schema names when
creating queries? If I don't specify a schema in my call to meta-
>setup, it produces SQL with my login ID hard-coded as the schema as
in:

select ...
from matt.product t1
...

What I want is for it to produce SQL like

select ...
from product t1
...

We are using Oracle and want to create SQL that will rely on public
synonyms to find the table rather than specifying the schema on every
table.

Anyone do this before? Sorry if this is a duplicate post, I did try
searching the group, but couldn't phrase my search in a way that
didn't bring back an overwhelming number of false positives.

Thanks!

-Matt

John Siracusa

unread,
Jan 19, 2012, 11:10:31 AM1/19/12
to rose-db...@googlegroups.com
On Wed, Jan 18, 2012 at 3:47 PM, Matt Forsythe <matt_f...@yahoo.com> wrote:
> Does anyone know how to tell Rose to leave off the schema names when
> creating queries?  If I don't specify a schema in my call to meta-
>>setup, it produces SQL with my login ID hard-coded as the schema as
> in:
>
> select ...
> from matt.product t1
> ...
>
> What I want is for it to produce SQL like
>
> select ...
> from product t1
> ...

I don't think this is possible without hacking or overriding internal
methods like fq_table_sql() in your Metadata class or
supports_schema() or schema() in your Rose::DB-derived class.

-John

Matt Forsythe

unread,
Jan 19, 2012, 3:40:02 PM1/19/12
to Rose::DB::Object
Looks like this worked:

use Rose::DB::Oracle;
package Rose::DB::Oracle;
sub supports_schema {0;}

It also looks like I can override it at the Metadata level as well:

use Rose::DB::Object::Metadata;
package Rose::DB::Object::Metadata;
sub select_schema {return undef;}

But probably safer to override it at the Oracle level. Thanks for the
suggestion.

-Matt

On Jan 19, 4:10 pm, John Siracusa <sirac...@gmail.com> wrote:

Matt Forsythe

unread,
Jan 19, 2012, 3:56:25 PM1/19/12
to Rose::DB::Object
Ooops, posted too soon. Obviously the better way is to extend
Rose::DB::Oracle:

package MyCompany::OracleNoSchema;

use strict;

use parent qw(Rose::DB::Oracle);

sub supports_schema {
return 0;
}

1;

And then call

__PACKAGE__->driver_class(oracle_no_schema =>
'MyCompany::OracleNoSchema');

inside of my Rose::DB subclass.
Reply all
Reply to author
Forward
0 new messages