Issue with CFScript Query of Query in Railo

CFML , ColdFusion , Railo Add comments

With the release of ColdFusion 9 you can do nearly everything in script syntax that you were able to do using tags, including executing queries. I'm not really sure when this feature was introduced in Railo (probably 3.2), but you can do this in Railo as well. However, I found one inconsistency today when doing a query-of-query using script syntax.

In ColdFusion, there is a dbtype argument to the execute() method of the Query object. So to do a query-of-queries you can just specify dbtype="query" when you execute your query:

// myQuery is a predifined query
// so I can execute a query against myQuery this way:
qoq = new Query();
qoq.setSQL("select * from myQuery where foo = 'bar'");

But when I ran this code in Railo (latest BER version 3.30.023). I got the error "Table 'mydsn.myQuery' doesn't exist"

So it was looking for a table in my db named 'myQuery' and seemed to ignore the dbtype="query" argument that I passed into the execute() function. Fortunately, you can look right into the workings of Railo's Query object by opening WEB-INF/railo/components/org/railo/cfml/Query.cfc, and by doing that you can see that there is no dbtype argument specified for execute(). However, it turns out that you can get it to work in Railo by using the setDBType() method.





Basically Query.cfc extends a Base.cfc component which uses onMissingMethod to enable using setters for passing in things that you would use attributes for in the tag version. So it's one extra line of code, but it works. And the good news is that it also works in ColdFusion 9. Since it is inconsistent with CF9, I submitted an issue for it. But I just thought I'd post this in case someone else runs into this issue.

2 responses to “Issue with CFScript Query of Query in Railo”

  1. Andrea Campolonghi Says:
    I am solving issue right now. I hope patch will appear in very next upgrade.
  2. Tony Garcia Says:
    And the issue has been resolved for version 3.3.024.
    Wow -- that was quick! Thanks Andrea!

Leave a Reply

Leave this field empty

Powered by Mango Blog. Design and Icons by N.Design Studio