Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use sequences not owned by DB user #780

Open
striker4150 opened this issue Mar 10, 2023 · 1 comment
Open

Cannot use sequences not owned by DB user #780

striker4150 opened this issue Mar 10, 2023 · 1 comment

Comments

@striker4150
Copy link

striker4150 commented Mar 10, 2023

Summary of problem or feature request

Hi, I cannot drop or get the current value of sequences that my user is not the owner of, even though my user has permission to create/nextval them. The sequence in question is in a schema not owned by my DB user. Is there some way I can disable the check when dropping/accessing sequences? Also, can the schema prefix be left out when querying for the sequence?

Code snippet of problem

DB::getSequence()->create('transaction_seq');  // Works

DB::enableQueryLog();  // Start of SQL logs below

$transaction_id = DB::getSequence()->currentValue('transaction_seq');  // Returns 0
$transaction_id = DB::getSequence()->nextValue('transaction_seq');  // Returns 1
$transaction_id = DB::getSequence()->currentValue('transaction_seq');  // Still returns 0
DB::getSequence()->drop('transaction_seq');  // Does not do anything

DB::getQueryLog();
-- Sequence name should NOT include the schema prefix "test", and my DB user is not the owner
select * from all_sequences where sequence_name=upper('test.transaction_seq') and sequence_owner=upper(user)
select test.transaction_seq.nextval as "id" from dual  -- It's fine to use the schema prefix for this query though
select * from all_sequences where sequence_name=upper('test.transaction_seq') and sequence_owner=upper(user)
select * from all_sequences where sequence_name=upper('test.transaction_seq') and sequence_owner=upper(user)

System details

  • Windows 10
  • PHP 8.1.15
  • Laravel 10.x
  • Laravel-OCI8 v10.3.0
@github-actions github-actions bot added the stale label Apr 11, 2023
Repository owner deleted a comment from github-actions bot Apr 15, 2023
@yajra yajra added pinned and removed stale labels Apr 15, 2023
@yajra
Copy link
Owner

yajra commented Apr 15, 2023

Does your connection have a prefix? I think this is the expected behavior. Maybe try creating a new connection without a prefix and use that instead.

DB::connection('no_prefix')->getSequence()->create('transaction_seq');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants