Ticket #27 (closed defect: fixed)

Opened 2 years ago

Last modified 1 month ago

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).

Change History

Changed 2 years ago by dhughes

  • status changed from new to closed
  • resolution set to fixed

(In [286]) Fixes #27. The problem was that when using query.returnObjectField or returnObjectFields, if the specified column names existed in multiple objects in the query all the instances of that column name were returned. These methods now insure that the returned fields are on the correct object.

Changed 1 month ago by anonymous

  • milestone deleted

Milestone Beta Candidate 2 (BC2) deleted

Note: See TracTickets for help on using tickets.