ptica / Oracle

2 stars 1 forks source link

listSources, describe unable to handle synonyms using db_link #16

Open ptica opened 10 years ago

ptica commented 10 years ago
ptica commented 10 years ago

the describe now can be hinted to use a dbLink and inspect the synonym source table:

class MyModel extends AppModel {
         // hints for Oracle::describe
        public $oracleDbLink = 'DB_LINK_NAME';
        public $oracleSrcTable = 'SRC_TABLE_FOR_SYNONYM';
ptica commented 10 years ago

the listSources problem could be solved by an app specific db driver with overloaded Oracle::listSources method with custom crafted sql (I did so as I needed to solve a timing issue as my production has had thousands of unrelated tables as well)

App::uses('Oracle', 'Oracle.Model/Datasource');
App::uses('DboSource', 'Model/Datasource');
class AppOracle extends Oracle {
       function listSources($data = null) {
                 ...
                 $sql = 'SELECT synonym_name AS name FROM all_synonyms where owner=... UNION SELECT table_name AS name FROM all_tables where owner=...