Oracle Auto Init PK Sequence - DB user, Not Sequence Owner

25 views
Skip to first unread message

Tom Adamo

unread,
Oct 18, 2012, 12:31:41 PM10/18/12
to rose-db...@googlegroups.com
I've been testing out the auto-init of RDBO objects with an Oracle database. I noticed the sequence value of my primary key column wasn't being populated correctly (the sequence I created follows the naming convention described in the Rose::DB::Object docs for auto-incremented columns). I tracked the problem down to the follow code in Rose::DB::Object::Metadata::Auto::Oracle:

In auto_init_primary_key_columns...

The code has this...

 32     my $sequence_name = uc $cm->auto_primary_key_column_sequence_name($table, $name);


The problem I have is that I'm not signed into the DB as the sequence owner, so this code needs to also supply the schema name so it will work regardless of which DB user I'm signed in as (and the proper grants are given). Something like this...

 32     my $sequence_name = uc $cm->auto_primary_key_column_sequence_name($schema . '.' . $table, $name);


I'm still trying to think of a work-around (we just use Oracle at this point), but I thought I'd point this out.

- Tom

Tom Adamo

unread,
Oct 19, 2012, 3:54:30 PM10/19/12
to rose-db...@googlegroups.com
Here's the work-around I'm testing out, just in case someone ever needs this for reference:

package Local::DB::Object::ConventionManager;
use base 'Rose::DB::Object::ConventionManager';

sub auto_primary_key_column_sequence_name {
    my ( $self, @params ) = @_;

    # Add the schema to the table name. This will make sure we find the
    # sequence on the database even if not connected as the sequence owner.
    $params[0] = $self->meta->schema() . '.' . $params[0];

    return $self->auto_column_sequence_name(@params);
}

Again, I'm only using Oracle here, so this should work out fine.


- Tom
Reply all
Reply to author
Forward
0 new messages