• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Possible Bug: Setting currentRow variable

New Here ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

My organization recently updated from CF2018 to CF2021 and I've encountered some odd behavior for which Google has been unable to provide an answer. The following line of code started throwing an error:

<cfset queryName.currentRow += queryName2.numberOfLines>

The error is:

There is a problem in the column mappings specified in the columnMap structure.The query attribute input does not contain any column by the name of currentRow. 

Even a simpler test throws the same error:

<cfset queryName.currentRow = '10'>

 I cannot figure out if this was an intentional change between CF2018 and CF2021 or a bug. I do know that it was not throwing an error in CF2018. Has anyone encountered something like this?

Paul Jarema
Adobe Certified Professional: ColdFusion

Views

263

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 06, 2023 Mar 06, 2023

ColdFusion 2021 is actually giving you a hint. QueryName.currentRow is actually a system property in ColdFusion. As such it already has a value. You can confirm this using the following line of code:

<p>Row number = <cfoutput>#queryName.currentRow#</cfoutput></p>

It is therefore wrong for the programmer to assign a value to queryName.currentRow. It just might be that you're seeing the error now because CF2021 is in general more accurate than CF2018.

  

Votes

Translate

Translate
Community Expert ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

ColdFusion 2021 is actually giving you a hint. QueryName.currentRow is actually a system property in ColdFusion. As such it already has a value. You can confirm this using the following line of code:

<p>Row number = <cfoutput>#queryName.currentRow#</cfoutput></p>

It is therefore wrong for the programmer to assign a value to queryName.currentRow. It just might be that you're seeing the error now because CF2021 is in general more accurate than CF2018.

  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2023 Mar 06, 2023

Copy link to clipboard

Copied

@BKBK Agree with your points.

 

My confusion stemmed from the fact that the code in my example worked fine without error (even if it was not correct) until CF was upgraded. If this was a flaw in CF2018 that was fixed in CF2021, I couldn't find anything in the release notes stating that.

 

If the error I'm getting now IS actually the intended behavior, I'm willing to accept that and implement a workaround to what my example is attempting to accomplish.

Paul Jarema
Adobe Certified Professional: ColdFusion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2023 Mar 07, 2023

Copy link to clipboard

Copied

LATEST

Hi @pauljarema ,

Your confusion is understandable. ColdFusion 2018 should have flagged the assignment

 

<cfset queryName.currentRow = '10'>

 

as an error. In any case, that line would have produced incorrect results! 😞

 

Although CF2018 tolerates the line, the value of queryName.currentRow is not necessarily 10, as you would expect. If the current row is 1, then the value of  queryName.currentRow will be 1. Irrespective of the assignment. In other words, the 10 is ignored. 

 

That is the behaviour in CF10, CF11, CF2016 and CF2018. In fact, in these CF versions, the following code works, with 1 as output.

 

<cfscript>
queryName = queryNew("id,name","Integer,Varchar", 
[ 
{id=1,name="One"}, 
{id=2,name="Two"}, 
{id=3,name="Three"} 
]); 

queryName.currentrow="abracadabra";
writedump(queryName.currentrow);
</cfscript>

 

 

Go to TryCF and see for yourself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation