Cfquery returntype Struct ordered or unordered?

In Lucee it is possible to give a returnType to the Query function. If I use type=Array, then I got an array with same order as the sql query result (although If I use in sql a order by)

What about the returntype=struct? When my query have a “order by” can I be sure, that the returned Struct is a ordered Struct or isn´t it? Or is it a linkedHashMap?

So if you use a return type of struct, the order will work in the same way you would expect a query object to work. If I set the order by clause in my SQL statement, it will be honored in the result set structure.

Regarding your question to whether it’s an ordered struct or LinkedHashMap: I’m not certain as the class type of the return is a Lucee class called QueryStruct. It would appear it’s some extension to a LinkedHashMap/Collection possibly.

Consider the following code which can be run here →

users = queryNew(
    "id, firstname", "integer, varchar",
        { "id":1, "firstname": "Han" },
        { "id":2, "firstname": "Chewie" }
subUsers = queryExecute(
    "select * from users order by firstname",
    { dbtype="query", returntype="struct", columnkey="id" }

dump( subUsers );
dump( subUsers.getClass() );

it’s an ordered struct, perhaps dump could include that information?