Ticket #2332 (closed defect: fixed)

Opened 7 months ago

Last modified 7 months ago

Oracle relationships fail when being generated from schema

Reported by: coolaj86 Owned by: jwage
Priority: major Milestone: 1.0.11
Component: Attributes Version: 1.1.2
Severity: abc Keywords:
Cc: Has Test: no
Status: Pending Core Response Has Patch: yes

Description

My Oracle DDL:  http://pastebin.com/f755003d8

What happens when I put in a print_r before the exception and and run Doctrine::generateModelsFromDb('models_new'):

Array
(
    [relations] => Array
        (
            [Computer] => Array
                (
                    [type] => 1
                    [alias] => Computer
                    [class] => Computer
                    [local] => COMPUTER_ID
                    [foreign] => ID
                )

        )

)

Fatal error: Uncaught exception 'Doctrine_Import_Builder_Exception' with message 'Missing class name.' in /home/hhpsprogrammer/Code/Doctrine-1.1.2-Sandbox/lib/Doctrine/Import/Builder.php:994
Stack trace:
#0 /home/hhpsprogrammer/Code/Doctrine-1.1.2-Sandbox/lib/Doctrine/Import.php(437): Doctrine_Import_Builder->buildRecord(Array)
#1 /home/sfprojects/Code/Doctrine-1.1.2-Sandbox/lib/Doctrine.php(704): Doctrine_Import->importSchema('models_new', Array, Array)
#2 /home/sfprojects/Code/Doctrine-1.1.2-Sandbox/test.php(4): Doctrine::generateModelsFromDb('models_new')
#3 {main}
  thrown in /home/sfprojects/Code/Doctrine-1.1.2-Sandbox/lib/Doctrine/Import/Builder.php on line 994

If I comment out the throw Exception statement and put an empty return instead it seems to work well enough. I just don't get why it's making the same relation over and over and over again.

Array
(
    [relations] => Array
        (
            [DeptTbl] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => DEPARTMENT_ID
                )

            [DeptTbl_8] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl_8
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => ID
                )

            [DeptTbl_13] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl_13
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => DEPT_ID
                )

        )

)
Array
(
    [relations] => Array
        (
            [DeptTbl] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => DEPARTMENT_ID
                )

            [DeptTbl_9] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl_9
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => ID
                )

            [DeptTbl_14] => Array
                (
                    [type] => 1
                    [alias] => DeptTbl_14
                    [class] => DeptTbl
                    [local] => DEPARTMENT_ID
                    [foreign] => DEPT_ID
                )

        )

)

Attachments

Oracle.php.patch Download (1.7 KB) - added by coolaj86 7 months ago.
changes all_constraintts to user_constraints

Change History

Changed 7 months ago by coolaj86

changes all_constraintts to user_constraints

Changed 7 months ago by coolaj86

  • has_patch set

It had something to do with the fact that it was grabbing constraints from all >5000 constraints in the database rather than just the 68 that exist in the space I'm operating from.

There's a huge difference select * from user_constraints; select * from all_constraints;

I've now attached a patch file

Changed 7 months ago by rouet

hi

the request that generates table relation from oracle schema is false. (i compare it with the mysql version)

the good version should be :

$sql = 'SELECT '

. 'rcc.table_name AS referenced_table_name, ' . 'lcc.column_name AS local_column_name, ' . 'rcc.column_name AS referenced_column_name ' . 'FROM user_constraints ac ' . 'JOIN user_cons_columns rcc ON ac.r_constraint_name = rcc.constraint_name ' . 'JOIN user_cons_columns lcc ON ac.constraint_name = lcc.constraint_name ' . "WHERE ac.constraint_type = 'R' AND ac.table_name = :tableName";

the bad version generate relations with one and many inverted.

regards

JR

Changed 7 months ago by jwage

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from New to 1.0.11

Fixed in r6145 and r6144

Note: See TracTickets for help on using tickets.