tracker issue : CF-3039634

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 79382:When you have a cfquery that within its body calls any cffunction that itself runs a cfquery, the containing cfquery will use the function’s query’s datasource and ignore the one passed to it as an at

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): David McGuigan / David McGuigan (David McGuigan)

Created: 08/11/2009

Components: Database, CFQuery

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 / 259360

Priority/Frequency: Normal / Unknown

Locale/System: English / Platforms All

Vote Count: 1

Problem:

When you have a cfquery that within its body calls any cffunction that itself runs a cfquery, the containing cfquery will use the function’s query’s datasource and ignore the one passed to it as an attribute.This can cause various problems, specifically in applications and systems that leverage more than one datasource, one of ColdFusion's biggest claim to fame ( its ability to connect to diverse and disparate non-ColdFusion systems seamlessly.      The following code will produce the error:        Table ’ds2DatabaseName.tableInDS1’ doesn’t exist        The query in the f function will execute correctly but the q1 query will be sent through the ds2 datasource ( the bug ).--------------------------------------------------------------------------------------------<cfquery name="q1" datasource="ds1">select * from tableInDS1<cfset f( ) />where 1 = 1</cfquery><cffunction name="f"><cfquery name="q2" datasource="ds2">select * from tableInDS2</cfquery></cffunction>
Method:

See this thread: https://prerelease.adobe.com/project/forum/thread.html?cap=87529bda13744b3db718e841890b9240&forid={a8760b70-42a5-45fc-8ba2-dfcf173a9580}&topid={f1ee42ec-446d-42e5-a616-4debe8c466c4}&tp=2&prr=0&a=added_r
Result:

Various

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3039634

External Customer Info:
External Company:  
External Customer Name: David McGuigan
External Customer Email: 5E0D54C04462BF5E992016B6
External Test Config: 08/11/2009

Attachments:

Comments:

This really confused me when I encountered this bug. Since I think nested queries would be bad coding practice, a good solution in my mind would be as simple as throwing an error when a nested query situation is encountered.
Vote by External U.
23101 | November 10, 2011 07:01:43 PM GMT