Torque
  1. Torque
  2. TORQUE-113

doDelete with invalid column should throw exception, not delete all rows

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.3
    • Fix Version/s: 4.0-beta1
    • Component/s: Runtime
    • Labels:
      None

      Description

      The following (incorrect) client code should cause an exception to be thrown. Instead of an exception, all rows in table T1 are deleted.

      T1Peer.doDelete(new Criteria().add(T2Peer.COL, 2));
      

      This code appeared in a project I am working on. The intent was to delete rows from table T2.

      Before the fix for TORQUE-93, this code had the intended effect becaue T1Peer.doDelete(criteria) just passed the criteria object to BasePeer.doDelete(criteria). Since the only reference BasePeer had to a table was table T2 in the criteria, only rows in table T2 were deleted.

      Now that T1Peer.doDelete(criteria) calls BasePeer.doDelete(criteria, TABLE_NAME) instead, the test if (crit.containsKey(key)) in BasePeer.processTables() always fails. This leads to an empty where clause, causing all rows in table T1 to be deleted.

      Expect: All Criterion objects in a Criteria should be used in the final where clause. If not, an exception should be thrown.

        Activity

        Julian Zinn created issue -
        Julian Zinn made changes -
        Field Original Value New Value
        Description The following (incorrect) client code should cause an exception to be thrown. Instead of an exception, all rows in table T1 are deleted.
        {code}
        T1Peer.doDelete(new Criteria().add(T2Peer.COL, 2));
        {code}

        This code appeared in a project I am working on. The intent was to delete rows from table T2.

        Before the fix for TORQUE-93, this code had the intended effect becaue {{T1Peer.doDelete(criteria)}} just passed the criteria object to {{BasePeer.doDelete(criteria)}}. Since the only reference BasePeer had to a table was table T2 in the criteria, only rows in table T2 were deleted.

        Now that {{T1Peer.doDelete(criteria)}} calls {{BasePeer.doDelete(criteria, TABLE_NAME)}} instead, the test {{if (crit.containsKey(key))}} in {{BasePeer.processTables()}} always fails. This leads to an empty where clause, causing all rows in table T1 to be deleted.

        Expect: An exception to be thrown if some Criterion object is not used in the final where clause.
        The following (incorrect) client code should cause an exception to be thrown. Instead of an exception, all rows in table T1 are deleted.
        {code}
        T1Peer.doDelete(new Criteria().add(T2Peer.COL, 2));
        {code}

        This code appeared in a project I am working on. The intent was to delete rows from table T2.

        Before the fix for TORQUE-93, this code had the intended effect becaue {{T1Peer.doDelete(criteria)}} just passed the criteria object to {{BasePeer.doDelete(criteria)}}. Since the only reference BasePeer had to a table was table T2 in the criteria, only rows in table T2 were deleted.

        Now that {{T1Peer.doDelete(criteria)}} calls {{BasePeer.doDelete(criteria, TABLE_NAME)}} instead, the test {{if (crit.containsKey(key))}} in {{BasePeer.processTables()}} always fails. This leads to an empty where clause, causing all rows in table T1 to be deleted.

        *Expect*: All Criterion objects in a Criteria should be used in the final where clause. If not, an exception should be thrown.
        Thomas Vandahl made changes -
        Fix Version/s 3.3 [ 12310991 ]
        Thomas Fox made changes -
        Assignee Thomas Fox [ tfischer ]
        Thomas Fox made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Thomas Fox made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Thomas Fox
            Reporter:
            Julian Zinn
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development