QoQ over agressively applies column aliases

Description

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

Environment

None

Activity

Show:

Zac Spitzer 27 July 2024 at 12:20

Isaiah Fischer 29 May 2018 at 19:54

Another bug that seems related (the over agressive qoq aliases): https://luceeserver.atlassian.net/browse/LDEV-272

Pothys - MitrahSoft 28 May 2018 at 15:21

I've added test case for this ticket & Confirmed the issue happened on lucee. If we use different column name for alias name from record set means it will return empty. Otherwise alias name is same as column name means its working fine. In ACF working as expected.

Pull Request: https://github.com/lucee/Lucee/pull/503

Unresolved

Details

Assignee

Reporter

Priority

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

Affects versions

Created 25 May 2018 at 17:33
Updated 27 July 2024 at 12:21