db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Birrer (JIRA)" <j...@apache.org>
Subject [jira] Commented: (TORQUE-89) OrderByColumn for COUNT, SUM
Date Sun, 15 Apr 2007 13:24:15 GMT

    [ https://issues.apache.org/jira/browse/TORQUE-89?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12488935

Stefan Birrer commented on TORQUE-89:

I see your point, so you basically mean this:

F(a) AS a.ca

should return a.ca, right?

So, I totally agree on your point about the removeSQLFunction() and it's
contract. You don't want to change that.

However, you may want to change processOrderBy() to fulfill it's contract of
ordering by a given column name. Currently it only supports columns that map
to an table column and don't support aggregation columns as in (COUNT(a) as
ca) which is at least supported in mysql.

To problem with this bug is that you can't work around b/c of the exception
being thrown at runtime. So the only way to solve is to modify the
processOrderBy(). The reason I touched removeSQLFunction is just to avoid it
to throw, conceptually the following lines have the same purposes (and this
is bad style I know but just to illustrate):

orderByColumn = "ca"; // from the example above

try {
    strippedColumnName = removeSQLFunction(orderByColumn);
} catch (TorqueException e) {
    // this is currently a failure scenario while indeed it could be an
aggregated column name
    strippedColumnName = orderByColumn;

CSA, Metis Enterprise Technologies LLC

> OrderByColumn for COUNT, SUM
> ----------------------------
>                 Key: TORQUE-89
>                 URL: https://issues.apache.org/jira/browse/TORQUE-89
>             Project: Torque
>          Issue Type: Bug
>          Components: Runtime
>    Affects Versions: 3.3-RC2
>         Environment: Linux
>            Reporter: Stefan Birrer
> I've a "complicated" JOIN statement that features some custom column like "COUNT(a) AS
> 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.

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: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message