Ticket #19 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Field alias does not work in ORDER BY

Reported by: sean@… Owned by: dhughes
Type: defect Priority: normal
Milestone: Component: Reactor - Gateway
Version: Severity: normal
Keywords: Cc:

Description

My Objects and Persistence wiki fails because ORDER BY does not seem to convert field aliases to field names.

Given a gateway gw, do gw.getAll("someAlias") and the order node has only fieldAlias in it and the generated SQL ends up with the alias instead of the actual field name.

If you fix line 632 of abstractGateway.cfc so that it refers to arguments.node.fieldName instead of fieldAlias (which solves some other aliasing bugs), then gw.getAll("someAlias") causes an exception at line 632 because arguments.node.fieldName does not exist (it exists for other get*() operations).

Change History

Changed 3 years ago by sean@…

Christopher Bradford posted this fix for the issue:

Thanks for pointing this out, Joe. I did run into one problem that this
solution creates: the appendNode method of the order object does not use the
fieldName key; rather, it uses the field key. Changing "fieldAlias" to
"fieldName" in the abstractGateway causes getFieldExpression to break when
it is called for an order field. I had to change the appendNode method of
the order object, line 38, from:

<cfset node.field =
getQuery().findObject(node.objectAlias).getObjectMetadata().getField(node.fieldAlias).name
/>

to:

<cfset node.fieldName =
getQuery().findObject(node.objectAlias).getObjectMetadata().getField(node.fieldAlias).name
/>

It seems to be working, but since I'm not intimately familiar with the code,
this could have unintended consequences.

Christopher Bradford

Changed 3 years ago by dhughes

  • status changed from new to closed
  • resolution set to fixed

This was fixed in changeset 282. Infact, the order object wasn't using the correct variable name which is why this fix initally caused problems with ordering.

Note: See TracTickets for help on using tickets.