** CF Wheels 1.4.5 column name delimiter **

80 views
Skip to first unread message

Robby Bankston

unread,
Sep 30, 2021, 10:36:22 AM9/30/21
to CFWheels
Good morning.

I have a legacy CF Wheels 1.4.5 app (currently can't be updated due to CF hosting limitation).  One problem I came across is with a few tables that have reserved words
as column names.  When we don't have control over the table schema to handle a column rename, is there a straightforward way to  allow/require column delimiters?

For example, the normal SQL query returned from wheels might look similar to this (with reserved public keyword).

SELECT CustomerID, Email, Public
FROM Customers
ORDER BY CustomerID

but this errors out due to the reserved word.  The desired SQL string would be similar to this with bracket column delimiters for SQL Server.

SELECT [CustomerID], [Email], [Public]
FROM Customers
ORDER BY [CustomerID]

I know the quickest way to fix this is to just rename the column, but sometimes the table structure is outside of your control, so is there a setting to configure this behavior in CF Wheels 1.4.5 or will I have to modify the code to allow?

It looked like $createSQLFieldList might be necessary to modify, but I'm not familiar enough with under the hood of CF Wheels to know everything that might have to change or whether this behavior already exists.

The delimiters in my scenario are [ and ] for Microsoft SQL Server but other DB platforms would use different characters accordingly.

Cheers,

Robby
Reply all
Reply to author
Forward
0 new messages