db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1138863 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
Date Thu, 23 Jun 2011 13:01:47 GMT
Author: tfischer
Date: Thu Jun 23 13:01:46 2011
New Revision: 1138863

URL: http://svn.apache.org/viewvc?rev=1138863&view=rev
Log:
TORQUE-113: Throw exception on invalid column in delete statement
TORQUE-118: Do not delete all records on a delete with a join

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java?rev=1138863&r1=1138862&r2=1138863&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/BasePeerImpl.java
Thu Jun 23 13:01:46 2011
@@ -344,12 +344,26 @@ public class BasePeerImpl implements Ser
         Query query = SqlBuilder.buildQuery(criteria);
 
         query.setType(Query.Type.DELETE);
-        query.getFromClause().clear();
+        
         String fullTableName = SqlBuilder.getFullTableName(
                 tableName,
                 criteria.getDbName());
-        query.getFromClause().add(
-                new Query.FromElement(fullTableName, null, null));
+        boolean ownTableAdded = false;
+        for (Query.FromElement fromElement : query.getFromClause())
+        {
+            // Table names are case insensitive in known databases
+            // so use case-insensitive compare
+            if (fullTableName.equalsIgnoreCase(fromElement.getTableName()))
+            {
+                ownTableAdded = true;
+                break;
+            }
+        }
+        if (!ownTableAdded)
+        {
+            query.getFromClause().add(
+                    new Query.FromElement(fullTableName, null, null));
+        }
         String sql = query.toString();
 
         PreparedStatement preparedStatement = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message