Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1628

onUpdate parameter on @JoinColumn not supported

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: Mapping Drivers
    • Labels:
      None

      Description

      It looks like this is in the older documentation (2.0) but not mentioned in the latest.

      I need to use ON UPDATE CASCADE in a few cases. Seems odd to support onDelete and not onUpdate. Am I missing something?

        Activity

        Hide
        Marco Pivetta added a comment -

        Kenneth Kataiwa updating identifiers is something you don't do, and I sincerely also don't have a use case for this, not in the context of an ORM at least. Also, handling changes in your identifiers in the UnitOfWork is a real problem that adds a lot overhead.

        Show
        Marco Pivetta added a comment - Kenneth Kataiwa updating identifiers is something you don't do, and I sincerely also don't have a use case for this, not in the context of an ORM at least. Also, handling changes in your identifiers in the UnitOfWork is a real problem that adds a lot overhead.
        Hide
        Václav Novotný added a comment -

        +1 - onUpdate attribute is very useful for PostgreSQL databases, it controls operations with foreign keys.

        I'm taking my words back. It is not a good idea to define onUpdate on foreign keys. Yes, PostgreSQL supports it but it doesn't mean that we should use it in ORM.
        Thanks for your time.

        Show
        Václav Novotný added a comment - +1 - onUpdate attribute is very useful for PostgreSQL databases, it controls operations with foreign keys. I'm taking my words back. It is not a good idea to define onUpdate on foreign keys. Yes, PostgreSQL supports it but it doesn't mean that we should use it in ORM. Thanks for your time.
        Hide
        Marco Pivetta added a comment -

        This issue is invalid, since data migration is not a task for the ORM anyway.

        Show
        Marco Pivetta added a comment - This issue is invalid, since data migration is not a task for the ORM anyway.
        Hide
        Gary Golden added a comment -

        I have a third party table which holds users:

        CREATE TABLE `user`
        (
        `user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `email` VARCHAR(255) NOT NULL UNIQUE,
        ) ENGINE=InnoDB CHARSET="utf8";

        In my table I want to use natural foreign key, so I reference `email`.

        CREATE TABLE `transaction` (
        `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
        `user_email` VARCHAR(255) NOT NULL,
        FOREIGN KEY (`user_email`) REFERENCES `user`(`email`)
        );

        I would like to RDBMS handle email updates on the foreign records.

        That is a real-life use case of the onDelete, which you decided to remove.
        Please, get it back if possible.

        Show
        Gary Golden added a comment - I have a third party table which holds users: CREATE TABLE `user` ( `user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `email` VARCHAR(255) NOT NULL UNIQUE, ) ENGINE=InnoDB CHARSET="utf8"; In my table I want to use natural foreign key, so I reference `email`. CREATE TABLE `transaction` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `user_email` VARCHAR(255) NOT NULL, FOREIGN KEY (`user_email`) REFERENCES `user`(`email`) ); I would like to RDBMS handle email updates on the foreign records. That is a real-life use case of the onDelete, which you decided to remove. Please, get it back if possible.
        Hide
        I. S. added a comment -

        I have a good use case and I am really missing the onUpdate cascade.
        However it is working inside a many-to-one association but not in a one-to-one association.
        The use case is a little complicated but I can send it to you if it could change something.

        Show
        I. S. added a comment - I have a good use case and I am really missing the onUpdate cascade. However it is working inside a many-to-one association but not in a one-to-one association. The use case is a little complicated but I can send it to you if it could change something.

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Chris Richard
          • Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: