<cfquery dbtype="hql"> returns a Query instead of an array (differs from Adobe ColdFusion and Lucee)

Title: <cfquery dbtype="hql"> returns a Query instead of an array (differs from Adobe ColdFusion and Lucee)

Versions

  • BoxLang 1.18.0+66 (MiniServer), Java 21 (Temurin 21.0.13), Windows 11
  • bx-orm 1.7.2+35, bx-compat-cfml 1.40.0+56
  • MariaDB 12.3 through bx-mysql

What happens
On Adobe ColdFusion and Lucee, <cfquery dbtype="hql"> returns an array: entities, scalar values, or arrays of values, the same result ormExecuteQuery() gives. On BoxLang it returns a ortus.boxlang.runtime.types.Query.

Code written for ACF/Lucee breaks on the first array access. For example, getData[1] throws Column '1' does not exist in query.

ormExecuteQuery() with the same HQL returns an array on BoxLang, as expected.

Minimal reproduction

Application.cfc:

<cfcomponent>
	<cfset this.name = "hqlReturnTypeTest">
	<cfset this.datasource = "myDsn">
	<cfset this.ormEnabled = true>
	<cfset this.ormSettings = { dbcreate: "update", cfclocation: expandPath("./ent") }>
</cfcomponent>

ent/Thing.cfc:

<cfcomponent persistent="true">
	<cfproperty name="ThingId" fieldtype="id" generator="native">
	<cfproperty name="ThingName" ormtype="string">
</cfcomponent>

test.cfm:

<cfset entitySave(entityNew("Thing", { ThingName: "one" }))><cfset ormFlush()>

<cfquery name="viaTag" dbtype="hql">SELECT ThingId FROM Thing</cfquery>
<cfset viaFunction = ormExecuteQuery("SELECT ThingId FROM Thing")>

<cfoutput>
tag: isArray=#isArray(viaTag)# isQuery=#isQuery(viaTag)#<br>
ormExecuteQuery: isArray=#isArray(viaFunction)#
</cfoutput>

Expected (Adobe ColdFusion 2023/2025 and Lucee):

tag: isArray=true isQuery=false
ormExecuteQuery: isArray=true

Actual (BoxLang 1.18 + bx-orm 1.7.2 + bx-compat-cfml 1.40):

tag: isArray=false isQuery=true
ormExecuteQuery: isArray=true

The same happens with <cfqueryparam> in the HQL.

I’m testing an existing CFML application on BoxLang. It uses <cfquery dbtype="hql"> in 326 places and reads the results as arrays (arrayLen(x), x[1], x[1]["Column"] for new Map(...) selects). That’s the documented behavior on both Adobe ColdFusion and Lucee, so the application stops at the first one.

Update: fixed in the bx-orm 1.7.3 snapshot (BLMODULES-306). Thank you!

Request
Could <cfquery dbtype="hql"> return the same array that ormExecuteQuery() returns, at least when bx-compat-cfml is installed? If BoxLang prefers a query by default, a compat setting to get the ACF/Lucee result would also work for us.

Thank you, and thanks for the module.

Gregory Alexander

Thank you, that was fast!
I tried the bx-orm 1.7.3 snapshot (built Nov 1, with BLMODULES-306) on BoxLang 1.18.0, and it works: <cfquery dbtype="hql"> now returns an array, with and without <cfqueryparam>, and entity selects (SELECT b FROM Blog b) and SELECT new Map(...) work too. Before, those last two went to MariaDB as SQL and failed.

With it, the Galaxie Blog installer gets through all of its HQL and creates the whole database on BoxLang. I am now working through the next few differences, and I’ll post them separately as we find them.