CakeDC / cakephp-oracle-driver

CakePHP 3 Driver for Oracle Database
Other
40 stars 25 forks source link

OracleBase inccorectly assumes that the tableName does not hold the schema too. #66

Closed Tyl13 closed 1 year ago

Tyl13 commented 2 years ago

Describe the Bug

When the driver tries to auto-increment the sequence, the table variable can hold the Schema. So,

select sequence_name from user_tab_identity_cols where table_name='$tableName' and column_name='$columnName'

comes back with no result since the table_name isn't expecting the Schema too. The other issue with the above is that it expects that the user to have a sequence for it that it may not.

To reproduce

Have a database setup that has a user with access to another Schema that is not its own. In the app_local config, set the schema to that one and the username to the user that has access to it. Make sure autoincrement is set to true and try to save a new item into a table without stating what its primary key should be set to. When it tries to do the first query in this function then it should return a result that is false.

Expected behavior

I expect the result to not be false because the sequence does exists, but it's table_name does not include the schema.

Impact on your work

The function does not work as intended and does not allow me to insert a new item into the table.

Additional context

This could probably be fixed in the lastInsertId function and just have the schema passed to the _autoincrementSequenceId function.