yajra / laravel-oci8

Oracle DB driver for Laravel via OCI8

Home Page:https://yajrabox.com/docs/laravel-oci8

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use sequences not owned by DB user

striker4150 opened this issue · comments

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

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');