Ticket #27 (closed defect: fixed)
Incorrect fields returned using returnObjectFields with join
| Reported by: | cbradford | Owned by: | dhughes |
|---|---|---|---|
| Type: | defect | Priority: | high |
| Milestone: | Component: | Reactor - Object Oriented Queries | |
| Version: | 1.0 | Severity: | major |
| Keywords: | join result fields | Cc: |
Description
I want to return the ID, title, and image fields from the graphic object (alias for Graphics table) and the bgCategory field from the imageCategory object (alias for GraphCategory table). I create a query on the graphicGateway and set up a join and returnObjectFields:
<cfset local.query.join("graphic", "imageCategory", "parentCategory")>
<cfset local.query.returnObjectFields("graphic", "ID,title,image") />
<cfset local.query.returnObjectField("imageCategory", "bgCategory") />
The imageCategory object is configured with a field alias of ID for GraphCategoryID and has a column named Title. These columns are erroneously requested in the generated query:
SELECT [graphic].[GraphicsID] AS [ID], [graphic].[Title] AS [Title], [graphic].[Image] AS [Image], [imageCategory].[GraphCategoryID] AS [ID], [imageCategory].[Title] AS [Title], [imageCategory].[bgCategory] AS [bgCategory] FROM [Graphics] AS [graphic] INNER JOIN [GraphCategory] AS [imageCategory] ON [graphic].[parentCategoryID] = [imageCategory].[ID] WHERE [graphic].[Keywords] LIKE (param 1) OR [graphic].[Keywords] LIKE (param 2) ORDER BY [graphic].[Title] ASC
As a result, the wrong values will be returned for ID and Title in this query (the last ones defined in the query).

