Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion 9.01 -> Lucee 5.3.3.62 and <cfinsert> / <cfupdate>

I’ve inherited a big application which is running on CF 9.01.
I’m in the process to port it to Lucee 5.3.3.62, but have some problems with and I know that I should replace it with , but this application has ~1000 source files (!!), and replacing all those tags is currently not obvious for timing reasons.
Lucee is throwing errors like:

“An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as “” or are not allowed. Change the alias to a valid name.”

At first, I thought there were problems with date field, because Lucee is handling them differently than CF 9.01, but this is not the case. So, I created a test table (on MS-SQL Server 2008R2):

CREATE TABLE [dbo].[LuceeTest01](   
  [Field1] [nvarchar](50) NULL,
  [Field2] [nvarchar](50) NULL ) ON [PRIMARY]

In Lucee, I’m using as datasource: Microsoft SQL Server (Vendor Microsoft), called “one”

This is my test application:

<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfoutput>
    <cfinsert datasource="one"
        tablename="LuceeTest01"
        formfields="Field1, Field2">
</cfoutput>

When I run this, I get the same error. Any idea why? Full trace here: https://justpaste.it/6k0hw

Thanks!

EDIT1:
Curious. I tried using “jTDS Type 4 JDBC Driver for MS SQL Server and Sybase” as datasource driver, and now the error is:

The database name component of the object qualifier must be the name of the current database.

This traces back to this statement:

{call []..sp_columns 'LuceeTest01', '', '', 'null', 3}

When I try this in the Microsoft SQL Server Management Studio, I get the same error. However, when I specify the database name (‘one’ as third argument), no error in MS SQL SMS.

EXEC sp_columns 'LuceeTest01', '', 'one', 'null', 3

Shouldn’t Lucee take this argument from the datasource configuration or something?

EDIT2:

As suggested by @Redtopia, when "tableowner" and "tablequalifier" are specified, it works for the jTDS driver. Will use this as workaround. Updated sample code:

<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfinsert datasource="onecfc"
    tableowner="dbo"
    tablename="LuceeTest01"
    tablequalifier="one"
    formfields="Field1,Field2">

EDIT3:

Bug filed here: https://luceeserver.atlassian.net/browse/LDEV-2566

like image 939
GunterO Avatar asked Nov 08 '19 14:11

GunterO


2 Answers

I personally would refactor CFINSERT into queryExecute and write a plain InsertInto SQL statement. I wish we would completely remove support for cfinsert.

like image 112
splls Avatar answered Nov 14 '22 17:11

splls


Consider using

<cfscript>
 Form.Field1 = "Field1";
 Form.Field2 = "Field2";

 // Don't forget to setup datasource in application.cfc
 QueryExecute("
    INSERT INTO LuceeTest01 (Field1, Field2)
    VALUES (?, ?)
    ",
    [form.field1, form.field2]
    );
</cfscript>
like image 1
James A Mohler Avatar answered Nov 14 '22 16:11

James A Mohler