Ticket #13 (closed defect: fixed)

Opened 2 years ago

Last modified 1 month ago

Field aliases in where clause doesn't work in MSSQL

Reported by: cbradford Owned by: dhughes
Type: defect Priority: highest
Milestone: Component: Reactor Samples - Reactor Blog
Version: Severity: minor
Keywords: alias mssql Cc:

Description

I have a field alias defined for a particular table (BookPagesID --> ID), and when Reactor generates the SQL for loading a Record of that type (reactorFactory.createRecord("Page").load(ID=1)), it uses the alias in the where clause. This is the Reactor-generated query:


SELECT [page].[BookPagesID] AS [ID], [page].[Active] AS [Active], [page].[ProjectID] AS [ProjectID], [page].[BookPageTypeID] AS [BookPageTypeID], [page].[PageNum] AS [PageNum], [page].[BackgroundImageID] AS [BackgroundImageID], [page].[BGAlpha] AS [BGAlpha], [page].[SubLayoutCatID] AS [SubLayoutCatID], [page].[TemplateTitle] AS [TemplateTitle], [page].[TemplateImage] AS [TemplateImage] FROM [BookPages] AS [page] WHERE [page].[ID] = (param 1)


MSSQL Server returns an error (it doesn't allow aliases in where clauses):


[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'ID'.


The same error occurs when running this query in Query Analyzer (substituting in the param value). Changing "WHERE [page].[ID]" to "WHERE [page].[BookPagesID]" works just fine.


For MSSQL, Reactor should use the original column name in all where clauses.

Change History

Changed 2 years ago by sean@…

This might be related to line 632 in abstractGateway.cfc which has arguments.node.fieldAlias in it (as of changeset [272]). If you change the reference to fieldName instead, I think this problem goes away (but then you'll run into issue #19 instead).

Changed 2 years ago by dhughes

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

This was fixed in changeset #282

Changed 1 month ago by anonymous

  • milestone deleted

Milestone Beta deleted

Note: See TracTickets for help on using tickets.