[ 
https://issues.apache.org/jira/browse/TORQUE-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590241#action_12590241
 ] 

Carl Manaster commented on TORQUE-113:
--------------------------------------

I'll chime in with a "me, too" on this - today I fixed a bug in code that had 
been working previously - deleting just one record - but that, with 3.3, 
started deleting all records, because the field name's case was wrong.  Since 
our database is case-insensitive, or since our configuration is 
case-insensitive, the SQL would be fine, regardless of case.  But now that 
BasePeer.ProcessTables() is asking the criteria to look up by exact string key, 
it fails if the case is wrong and comes up with an empty WHERE clause, deleting 
all records.  I agree that it would be better to throw an exception in this 
case than to delete all records, although ideally (to my mind), torque would 
honor the case sensitivity of the underlying database.

I should say: I don't know how it worked before 3.3; I'm just assuming that 
something different was going on in ProcessTables(), because that's clearly 
where it is building the WHERE clause and clearly where it is failing.  But 
it's possible that the criteria was converting all its keys to uppercase or 
something - I don't know, and don't want to send the maintainer on a wild goose 
chase.  It's just where the problem appears to be, to me.

> doDelete with invalid column should throw exception, not delete all rows
> ------------------------------------------------------------------------
>
>                 Key: TORQUE-113
>                 URL: https://issues.apache.org/jira/browse/TORQUE-113
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.3
>            Reporter: Julian Zinn
>             Fix For: 3.3, 4.0
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to