Confirmed - this is a bug caused by Velocity processing specifics - when a Velocity macro appears at the end of the line, the line break disappears from the processed query. I opened a bug report:

http://issues.apache.org/cayenne/browse/CAY-726

Andrus



On Dec 26, 2006, at 11:25 AM, Gary Jarrel wrote:

Hi All!

Just came across some interesting behavior while creating Raw Select
Queries in the modeler.

If my query looks like:

SELECT #result('count(*)' 'int' 'RECORDCOUNT')
FROM message JOIN user ON message.client_id = user.client_id
WHERE message.inbound = #bind($inboundStatus)
#if($userID)
   AND user.client_id = #bind($userID)
#end

I get a SQLException as the new line character from the first to
second line is ignored and the SQL in the log looks like:

SELECT count(*) AS RECORDCOUNTFROM message JOIN user ON
message.client_id = user.client_id
WHERE message.inbound = ?    AND user.client_id = ?]

However if I restructure the query in the modeler to:

SELECT #result('count(*)' 'int' 'RECORDCOUNT') FROM message JOIN user
ON message.client_id = user.client_id
WHERE message.inbound = #bind($inboundStatus)
#if($userID)
   AND user.client_id = #bind($userID)
#end

i.e SELECT and FROM on the same line with a space before FROM, all is well?

Anyone else come across this?

Cheers,

garyj


Reply via email to