Details
Assignee
Michael OffnerMichael OffnerReporter
dan.switzer@givainc.comdan.switzer@givainc.comPriority
NewNew Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
dan.switzer@givainc.com
dan.switzer@givainc.comPriority
New Issue warning screen
Before you create a new Issue, please post to the mailing list first https://dev.lucee.org
Once the issue has been verified, one of the Lucee team will ask you to file an issue
Affects versions
Created 27 January 2022 at 21:08
Updated 17 August 2022 at 13:47
I'm running into a very weird issue with
<cfquery />
when theattributeCollection
is used to propagate it's attributes when the code is inside a<cffinally />
block. When run, the code ends up throwing an exception like:Attribute [datasource] is required when attribute [dbtype] is not [query] and no default datasource is defined on line XXX
I've put together an example of this on TryCF:
https://www.trycf.com/gist/736058f17b9841bb53bf7e2fc198d4d7/lucee5?theme=monokai
<cfscript> x = queryNew("a,b,c", "varchar,varchar,varchar", [[1, 2, 3], [4, 5, 6], [7, 8, 9]]); attrs = {name="y", dbtype="query"}; </cfscript> <cftry> <cfset z = "" /> <cffinally> <cfquery attributeCollection="#attrs#"> select * from x where a > 2 </cfquery> </cffinally> </cftry> <cfdump var="#y#" />
While this code is use QoQs, the same code with a
datasource
defined also throws an error. It's just easier to show off using QoQ since TryCF doesn't support database connections.If you change this code to move the
<cfquery />
block outside the<cffinally />
block, the code executes as you'd expect.