Doctrine 1
  1. Doctrine 1
  2. DC-764

Major->please.....Value of Primary key from sequence in Postgres table NOT being set (although sequence gets incremented)

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.2.1
    • Fix Version/s: 1.2.0, 1.2.1, 1.2.2, 1.2.3
    • Component/s: Connection, Record
    • Labels:
      None
    • Environment:
      Ubuntu9.10 / PHP 5.2.6-3ubuntu4.5 with Suhosin-Patch 0.9.6.2 / Postgres-8.4 / Symfony 1.4.1

      Description

      In the ERD/schema that I have set up, a couple levels down in hierarchal order, a table has 3 composite foreign keys, and one sequence of its own. That sequence does not get get set into the 'Table->sequence variable'. That means when the file 'UnitOfWork' executes the function '_assignSequence()', it finds no sequence name, and skips the assignment of the sequence value.

      This of course blows up my inserts.

      I have included the following documentation:

      A/ An installation and further description README.tx file.
      B/ SQL script to generate a anonymous version of my ERD - I.E. the table names and column names have been changed to protect the guilty (and proprietary)
      C/ A fixture file to load some data.
      D/ A *.png file showing a graphical view of the ERD.
      E/ The generated schema.yml file from ./symfony doctrine:build-schema
      F/ A modifiled (has certain echo statements for troubleshooting purposes) UnitOfWork.php file.
      G/ A task file to run that tries to load the schema with valid values.
      H/ An output file from running the Task and modified UnitOfWork.php file showing the exact point of error during insert.

      Please let me know what I can do to help get this troubleshot quicly. Thx
      E/

        Activity

        Hide
        Dennis Gearon added a comment -

        Don't know if it's related, but I ran:

        ./symfony doctrine:build-sql

        on the database in this bug report, and none of the tables got sequences assigned to them, nor default values set coming from a sequence.

        This is Postgres.

        Show
        Dennis Gearon added a comment - Don't know if it's related, but I ran: ./symfony doctrine:build-sql on the database in this bug report, and none of the tables got sequences assigned to them, nor default values set coming from a sequence. This is Postgres.
        Hide
        Dennis Gearon added a comment -

        So much for getting around this problem easily,

        I tried doing this:

        $e_table=Doctrine::getTable('E');
        $e_table->setOption('sequenceName', 'e_id');
        $e_options=$e_table->getOptions();
        var_dump($e_options);

        before inserting a record into the 'E' table. The option value 'sequenceName' is in the option array and returns correctly. However, when doing an insert immediatley after the above code, I get:

        'sequence name was Array' (from my troubleshooting 'echo' statements in the modified UnitOfWork.php file)

        and the following errors: (you have to be using my modified UOW.php file to get the same line number there.)

        Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php on line 917

        Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2222

        Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2223
        PREVIOUS line was processingSingleInsert

        Warning: Invalid argument supplied for foreach() in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 1151

        So I am wondering, does the public function table->setOption(); even work, correclty that is?

        Show
        Dennis Gearon added a comment - So much for getting around this problem easily, I tried doing this: $e_table=Doctrine::getTable('E'); $e_table->setOption('sequenceName', 'e_id'); $e_options=$e_table->getOptions(); var_dump($e_options); before inserting a record into the 'E' table. The option value 'sequenceName' is in the option array and returns correctly. However, when doing an insert immediatley after the above code, I get: 'sequence name was Array' (from my troubleshooting 'echo' statements in the modified UnitOfWork.php file) and the following errors: (you have to be using my modified UOW.php file to get the same line number there.) Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection/UnitOfWork.php on line 917 Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2222 Warning: Illegal offset type in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 2223 PREVIOUS line was processingSingleInsert Warning: Invalid argument supplied for foreach() in /home/bugreport/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 1151 So I am wondering, does the public function table->setOption(); even work, correclty that is?
        Hide
        Dennis Gearon added a comment -

        If I instead just retrieve the next val of the sequence manually, change 'id' column manually, then it works. But It then fails on the insert into the 'J' table.

        Apparently, Doctrine does not like composite primary foreign keys with a sequence also part of the foreign key. I wonder if my file would work on the Oracle version?

        Show
        Dennis Gearon added a comment - If I instead just retrieve the next val of the sequence manually, change 'id' column manually, then it works. But It then fails on the insert into the 'J' table. Apparently, Doctrine does not like composite primary foreign keys with a sequence also part of the foreign key. I wonder if my file would work on the Oracle version?
        Hide
        Dennis Gearon added a comment -

        Showing simpler version of ERD/Schema converting Primary Foreign Keys to Foreign keys. The then required unique index on the former Primary Foreign Keys has not yet been coded. Just create it on all the keys in tables E and J, that were listed as primary in the first version in the zip file

        Show
        Dennis Gearon added a comment - Showing simpler version of ERD/Schema converting Primary Foreign Keys to Foreign keys. The then required unique index on the former Primary Foreign Keys has not yet been coded. Just create it on all the keys in tables E and J, that were listed as primary in the first version in the zip file
        Hide
        Dennis Gearon added a comment -

        See last comment, but the short answer is . . . at this date, 2010-06-25, even Doctrine 2.0-DBAL can't do what I'm trying to get verson 1.2.1 to do.

        So I got around it by converting primary foreign keys to foreign keys and then putting a unique index on the formerly primary keys.

        However, the child of the table treated that way, E(parent), J(child), now only has one foreign key, for E. To get all the ancestors, I will have to do subselects and joins. Oh well.

        Show
        Dennis Gearon added a comment - See last comment, but the short answer is . . . at this date, 2010-06-25, even Doctrine 2.0-DBAL can't do what I'm trying to get verson 1.2.1 to do. So I got around it by converting primary foreign keys to foreign keys and then putting a unique index on the formerly primary keys. However, the child of the table treated that way, E(parent), J(child), now only has one foreign key, for E. To get all the ancestors, I will have to do subselects and joins. Oh well.

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Dennis Gearon
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: