QoQ doesn't support "column=value" rather than "value as alias"

Description

<cfset qry= queryNew("name,age,whatever", "varchar,date,int", [
[ "Susi", CreateDate( 1970, 1, 1 ), 5 ],
[ "Urs" , CreateDate( 1995, 1, 1 ), 7 ],
[ "Fred", CreateDate( 1960, 1, 1 ), 9 ],
[ "Jim" , CreateDate( 1988, 1, 1 ), 11 ]
])>
<!-- bad example, not using a bound parameter, unsafe when using input from users -->
<!-- using a bound parameter with cfqueryparam -->
<cfquery name="q" dbtype="query">
select bug=null from qry
</cfquery>
<cfdump var="#q#" />


within sql it is possible to use SELECT bug = NULL and SELECT NULL AS bug
however when SELECT bug = NULL is used within dbtype=”query” it shows column_0 with true values in both lucee 5 and 6

Environment

None

Activity

Brad Wood 6 September 2023 at 14:07

That’s another “bug” that was fixed in QoQ. Trying to union two queries with different columns is illegal. The old QoQ used to let you get away with it, but we closed the loop hole.

Axel Bons 6 September 2023 at 11:36

The example from select foo=null was not in use, but I tried using it in some QoQ changes

Axel Bons 6 September 2023 at 11:33

The given example was a simple change in the script in

<cfscript>
qry= queryNew("name,age,whatever", "varchar,date,int", [
[ "Susi", CreateDate( 1970, 1, 1 ), 5 ],
[ "Urs" , CreateDate( 1995, 1, 1 ), 7 ],
[ "Fred", CreateDate( 1960, 1, 1 ), 9 ],
[ "Jim" , CreateDate( 1988, 1, 1 ), 11 ]
])
query name="q" dbtype="query" {
echo("select name from qry union select age, whatever from qry");
}
writedump(q);
</cfscript>

Zac Spitzer 6 September 2023 at 09:27

hmmm, do you have the stack trace from the full example, does it include some hsqldb files?

Axel Bons 6 September 2023 at 08:40

Thanks for the clarification.

We prefer the syntax select foo = bar, we didn't know it was deprecated, we still use it in SQL server 2017 (and also works in 2019)

I found this inconsistency with SQL while updating some breaking changes since lucee 4.5 update on QoQ’s with a union containing different columns.
select name from qry union select age, whatever from qry

In 4.5 this query was ok and had the columns name, age and whatever
We used this to combine different query results together which have some the same and some extra columns just to be able to sort and loop

I think this was a very useful feature:

select * from rs1
union all
select * from rs2

now needs to be changed to

select <combinedcolumnlist logic with null as missingcolumn> from rs1
union all
select <combinedcolumnlist logic with null as missingcolumn> from rs2

Won't Do

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

Created 4 September 2023 at 10:19
Updated 6 September 2023 at 14:07
Resolved 5 September 2023 at 18:18