升级到ColdFusion 9得到奇怪的cfif错误

Bri*_*Bri 2 coldfusion coldfusion-9

我有几个地方有这样的代码:

<cfinvoke component="#application.path#cfc/eval_faculty" method="getPresentations" returnvariable="presentations">
    <cfinvokeargument name="id" value="#eval_id#">
    <cfinvokeargument name="evalYear" value="#eval_semester#">
    <cfinvokeargument name="department" value="#general.dept#">
</cfinvoke>

<cfset prescheck = 0>
<cfloop query="presentations">
    <cfif local eq "" and regional eq "" and national eq "" and international eq "">
        <cfset prescheck = prescheck+1>
    </cfif>
</cfloop>
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Complex object types cannot be converted to simple values.
Run Code Online (Sandbox Code Playgroud)

cfif语句中的这些值都不是复杂对象.

这在ColdFusion 8中运行良好.我们刚刚升级到ColdFusion 9 ...

错误发生在行上 <cfif local eq "" ... >

有任何想法吗?

Lei*_*igh 7

<cfif local eq ""
Run Code Online (Sandbox Code Playgroud)

这可能是因为LOCAL现在是在CF9,就像一个系统范围FORM,URL,etecetera.所以当你尝试对它进行字符串比较时,CF会抱怨,因为它是一个结构.如果LOCAL在旧代码中表示一个简单变量,请尝试使用其他变量名称.

更新:从注释中,如果LOCAL是查询中列的名称,则可以使用sql别名为其指定另一个名称:

  SELECT Local AS LocalAlias FROM Table
Run Code Online (Sandbox Code Playgroud)

...或使用完全限定的变量名称:

   <cfif queryName.local ...>
Run Code Online (Sandbox Code Playgroud)

  • @Al - 对,但完全限定名称,即`queryName.Local`应该避免这种情况. (2认同)