Issue Details (XML | Word | Printable)

Key: TORQUE-89
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Thomas Fischer
Reporter: Stefan Birrer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Torque

OrderByColumn for COUNT, SUM

Created: 15/Apr/07 10:03 AM   Updated: 24/Sep/07 08:32 PM
Return to search
Component/s: Runtime
Affects Version/s: 3.3-RC2
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Linux


 Description  « Hide
I've a "complicated" JOIN statement that features some custom column like "COUNT(a) AS ca".

Torque runtime fails on the

Criteria::addAscendingOrderByColumn("ca")

because it expects a full qualified table.columnName which is not the case for the example "ca" column.

The problem can be fixed by adapting the following functions (3.3-RC2):
src/java/org/apache/torque/util/SQLBuilder.java
removeSQLFunction(final String name) : name must not necessarily contain '.' or '*" thus replacing the first thrown exception with a "return name" fixes that issue
processOrderBy(...) : in the for loop, strippedColumnName must not contain '.' hence replacing the first thrown exception with "orderByColumn.add(orderByColumn); break;" fixes the issue

This are quick fixes and I guess you want to reconsider whether you want to implement it that way. After these two changes, it was working correctly though.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #535596 Sun May 06 10:47:39 UTC 2007 tfischer OrderBy now accepts column names without a dot. No additional processing is made for these.
Partially fixes TORQUE-89. Thanks to Stefan Birrer for proposing the change.
Files Changed
MODIFY /db/torque/site/trunk/xdocs/changes.xml
MODIFY /db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java