Yep -- we had to patch this over here. You can't order by aliased columns or
tables. If you're interested, let me know.
In theory, all we did was check if the value you're attempting to order by
is also an alias. If it is, let it through as-is. Otherwise, use the current
table.column check.
- Justin
-----Original Message-----
From: Tulsi Das [mailto:quixote_arg@yahoo.com]
Sent: Tuesday, October 07, 2003 5:32 PM
To: torque-user@db.apache.org
Subject: Alias order by problem...
Hello, using Torque with MySQL I want to do an "order by" using some
alias column and not a table column. That is, something like this:
SELECT actividad.*, MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') AS
score FROM actividad
WHERE MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') order by score
desc
that is, using full text seach, sort by the score of that result.
To achieve that, I use the following code:
String matchString = "MATCH ("+ActividadPeer.ACTIVIDAD+") AGAINST
(\'"+texto+"\')";
Criteria crit = new Criteria();
crit.add(ActividadPeer.ACTIVIDAD, (Object)matchString,
Criteria.CUSTOM);
crit.addAsColumn("score", matchString);
crit.addDescendingOrderByColumn("score");
List actividades = ActividadPeer.doSelect(crit);
If I comment the addDescendingOrderByColumn line, everything goes well
and the full text goes ok, but when trying to do the order by, I get
the following error:
org.apache.torque.TorqueException: Malformed column name in Criteria
order by: 'score DESC' is not of the form 'table.column'
Now... I know it what it means, but I don´t want a table.column form,
since it´s an alias!
Any input on the subject will be much appreciated
thanks
Tulsi
------------
Internet GRATIS es Yahoo! Conexión
4004-1010 desde Buenos Aires. Usuario: yahoo; contraseña: yahoo
Más ciudades: http://conexion.yahoo.com.ar
---------------------------------------------------------------------
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
|