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 Tom Lianza <tl...@hotmail.com> on 2005/01/22 20:09:19 UTC

Select clause affects FROM clause?

Hi all,

I'm having some problems with adding a select clause... it seems as if 
Torque is adding a FROM clause that is inappropriate, and I'm not sure why 
it's doing it.

I am using mysql and want to use some db-specific functions.  I have no 
problems adding a select clause to my criteria like this:

crit.addSelectColumn("MAX("+TbldeliveryitemPeer.QUANTITYSHIPPED+")");

That gives me a nice MAX.  However, if I do something like this:

crit.addSelectColumn("TO_DAYS(max("+TbldeliveryPeer.INVOICEDATE+"))");

Then the query that torque spits out adds that to the select clause 
appropriately, but then for some reason changes my FROM clause and appends 
this string to it:

max(tbldelivery

Just before the WHERE clause starts.  I have no idea what it's doing, but i 
seems to be just taking a slice of my select clause (it doesn't even close 
off the parentheses) and generates obviously bad SQL that the database can't 
use.  I'm using Torque 3.0.2.  If this is fixed in a later release I'd 
possibly upgrade, but last time I tried I remember it being fairly painful.

Thanks!
Tom



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


RE: Select clause affects FROM clause?

Posted by Thomas Fischer <Fi...@seitenbau.net>.




Hi,

this problem arises  because torque needs to guess the name of the table
where you want to select from from the selectColumn. This is not done
correctly up to and including Torque 3.1.1 if more than one bracket pair is
used in the selectColumn, but it is fixed in the TORQUE_3_1_branch in CVS.

    Thomas

"Tom Lianza" <tl...@hotmail.com> schrieb am 22.01.2005 20:09:19:

> Hi all,
>
> I'm having some problems with adding a select clause... it seems as if
> Torque is adding a FROM clause that is inappropriate, and I'm not sure
why
> it's doing it.
>
> I am using mysql and want to use some db-specific functions.  I have no
> problems adding a select clause to my criteria like this:
>
> crit.addSelectColumn("MAX("+TbldeliveryitemPeer.QUANTITYSHIPPED+")");
>
> That gives me a nice MAX.  However, if I do something like this:
>
> crit.addSelectColumn("TO_DAYS(max("+TbldeliveryPeer.INVOICEDATE+"))");
>
> Then the query that torque spits out adds that to the select clause
> appropriately, but then for some reason changes my FROM clause and
appends
> this string to it:
>
> max(tbldelivery
>
> Just before the WHERE clause starts.  I have no idea what it's doing, but
i
> seems to be just taking a slice of my select clause (it doesn't even
close
> off the parentheses) and generates obviously bad SQL that the database
can't
> use.  I'm using Torque 3.0.2.  If this is fixed in a later release I'd
> possibly upgrade, but last time I tried I remember it being fairly
painful.
>
> Thanks!
> Tom
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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