Ticket #32 (closed defect: fixed)
Multi Column Join Error (includes fix to join.cfc)
| Reported by: | m.lesko@… | Owned by: | dhughes |
|---|---|---|---|
| Type: | defect | Priority: | normal |
| Milestone: | Component: | Reactor - Object Oriented Queries | |
| Version: | 1.0 | Severity: | normal |
| Keywords: | JOIN | Cc: |
Description
Happens when doing a join between two tables involving more than one column. The "ON" returned as part of the join is included more than once, when it should only be there one time.
Fix to lines 29-33 of join.cfc:
<!--- add the ON --->
<cfset join = join & " ON ">
<cfloop from="1" to="#ArrayLen(relationship.relate)#" index="x">
<!--- <cfset join = join & " ON " & arguments.Convention.formatFieldName(FromObject.getObjectMetadata().getField(relationship.relate[x].from).name, arguments.FromObject.getAlias()) /> --->
<cfset join = join & arguments.Convention.formatFieldName(FromObject.getObjectMetadata().getField(relationship.relate[x].from).name, arguments.FromObject.getAlias()) />
<cfset join = join & " = " & arguments.Convention.formatFieldName(Object.getObjectMetadata().getField(relationship.relate[x].to).name, getObject().getAlias()) />
<!--- if we're related by more than one column then add an and and repeat! --->
<cfif x IS NOT ArrayLen(relationship.relate)>
<cfset join = join & " AND " />
</cfif>
</cfloop>

