Unresolved
Details
Assignee
Michael OffnerMichael OffnerReporter
Isaiah FischerIsaiah FischerPriority
MajorLabels
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
Details
Details
Assignee
Michael Offner
Michael OffnerReporter
Isaiah Fischer
Isaiah FischerPriority
Labels
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
Created 25 May 2018 at 17:33
Updated 27 July 2024 at 12:21
My use case for this is joining two record sets on a column, and in the select section pulling a different column and aliasing it as the column that is being used to join. The alias seems to preemptively happen, causing the join to fail (as the values won't line up anymore).
```
<cfscript>
rs = QueryNew('foo,bar','integer,integer',[[1,2],[3,4]]);
rs2 = QueryNew('zap,bar','integer,integer',[[5,2],[6,4]]);
WriteDump(rs);
WriteDump(rs2);
</cfscript>
<!--- It appears that the `rs2.zap as bar` is happening before the `rs.bar = rs2.bar` so when it does do the comparison it's comparing rs.bar to rs2.zap --->
<cfquery dbtype="query" name="what">
select rs2.zap as bar
from rs, rs2
where rs.bar = rs2.bar
</cfquery>
<cfdump var="#what#">
<cfquery dbtype="query" name="see">
select rs2.zap as bar2
from rs, rs2
where rs.bar = rs2.bar
</cfquery>
<cfdump var="#see#">
```
The query works fine if I use a different alias, but then I'd need to run another QoQ to change the name of the column to what i needs to be so the rest of the code will continue to work properly.
This code functions correctly in ACF11, 2016, and 2018 (didn't try others), and doesn't work on Lucee 4.5 or Lucee 5
https://trycf.com/gist/d48538e38b9b8d16486dc0726f705ee5/lucee5?theme=monokai