DeleteRule: Nullify vs isMandatory

From: Andriy Shapochka (ashapochk..otmail.com)
Date: Sun Feb 02 2003 - 12:39:52 EST

  • Next message: Craig Miskell: "Re: DeleteRule: Nullify vs isMandatory"

    Seemingly, DeleteRule.NULLIFY is allowed to coexist with the related DbAttribute.isMandatory == true by the current implementation. Consider the scenario:
    CREATE TABLE A (
      A_ID INTEGER NOT NULL,
      CONSTRAINT A_PK PRIMARY KEY (A_ID),
    );
     
    CREATE TABLE B (
      B_ID INTEGER NOT NULL,
      A_ID INTEGER NOT NULL,
      CONSTRAINT B_PK PRIMARY KEY (B_ID),
      CONSTRAINT B_FK FOREIGN KEY (A_ID) REFERENCES A (A_ID)
    );
     
    If A -> B obj relationship has DeleteRule.NULLIFY Cayenne will try to nullify B.A_ID and the commit will fail. Maybe it would be better to disallow such a situation checking data maps at the early stages and denying combinations like the above mentioned (CASCADE or DENY only allowed in this case). Then it will closely correspond to a straight database modification scenario:
    1) Reassign foregn keys to appropriate values manually
    2) Delete the dereferenced object in question.
     
    What do everybody think? Should it be done or do I overlook some piece of the code already handling this matter?
     
    Andriy.



    This archive was generated by hypermail 2.0.0 : Sun Feb 02 2003 - 12:39:08 EST