You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Gary Jarrel <ga...@gmail.com> on 2006/12/26 10:25:20 UTC
A bug perhaps?
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
Re: A bug perhaps?
Posted by Andrus Adamchik <an...@objectstyle.org>.
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
>