You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Edgar González <eg...@valhallaproject.com> on 2003/01/03 15:25:38 UTC

[PATCH] orderBy when use alias

Hi,

Here is a patch to orderBy when use alias.

The bug happens when you use alias and specify an orderBy with an string column
of the table aliases, the code add a new column to the select clause with the ignoreCaseInOrderBy database function. The problem is that when the column is added to the select clause not use the alias name specified, instead use the table name, and if the table name is not used in the query an SQL error ocurrs


Index: BasePeer.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/util/BasePeer.java,v
retrieving revision 1.57
diff -u -r1.57 BasePeer.java
--- BasePeer.java 12 Dec 2002 14:53:28 -0000 1.57
+++ BasePeer.java 3 Jan 2003 14:07:04 -0000
@@ -1280,7 +1280,7 @@
                                 + orderByColumn.substring(spacePos));
                     }
                     selectClause.add(
-                        db.ignoreCaseInOrderBy(table + '.' + columnName));
+                        db.ignoreCaseInOrderBy(tableName + '.' + columnName));
                 }
                 else
                 {


----------------------------------------------------------------------------
Edgar Gonzalez Gonzalez
VALHALLA Project, s.a.
Chief Technology Officer
Web: www.valhallaproject.com
E-mail: egg@valhallaproject.com
Phone: +58-212-242.4379 / 6662 / 4055 / 6475
Fax: +58-212-242.6809

"The limits of my language mean the limits of my world."
Ludwig Wittgenstein

----------------------------------------------------------------------------