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

query(querycolumn).toArray() broken

Explorer ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

We updated our Coldfusion 2018 installations to the recent version 12.

After this update code of the form <queryname>("<querycolumn>").toArray(), which worked the way ValueArray(x,x) worked before, is broken.
Is there any way to get compatibility here or do we have to change the application?

Views

575

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 ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

It may not be the toarray but rather what's in the query that's broken. If that query is fed by a query of queries, yes there's a bug with that in the Sept updates, and yes Adobe has a fix. Email them at cfsup@adobe.com to ask for it, which will includes simple steps to apply the fix. 


/Charlie (troubleshooter, carehart.org)

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
Explorer ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

Thanks Charlie, but the query of query bug is already installed on our servers! I think it really is the toArray function. The Error message is: the toArray() method was not found
MethodSelectionException

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
Explorer ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

of course the fix is installed, not the bug 🙂

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
Explorer ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

We now have fixed all uses of the toArray function on a query-column  by using ValueArray and so the problem is fixed for us. Nevertheless I would like to know why this worked earlier and now is broken.

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 ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

quote

... I would like to know why this worked earlier and now is broken.


By @elisabethf82215657

 

I hope you are satisfied with my answer.

 

 

We now have fixed all uses of the toArray function on a query-column  by using ValueArray and so the problem is fixed for us.

 

Good move. All's well that ends well. 🙂

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 ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

quote

After this update code of the form <queryname>("<querycolumn>").toArray(), which worked the way ValueArray(x,x) worked before, is broken.


By @elisabethf82215657

 

Uhrm, do you mean something like the following?

 

<cfset myQueryColumnArray=myQuery("myColumn").toArray()>

 

If so, then I can see why ColdFusion doesn't tolerate this any longer. When you write it like that, you immediately see that it is incorrect CFML code. It is ambiguous to start with. It suggests that myQuery is a function that accepts as argument the string"myColumn". Which doesn't make sense.

 

It is what is usually called an undocumented method. The fact that it worked in the past doesn't necessarily make it OK. In general, ColdFusion changes for the better. So it would have dropped whatever it was that made that query code to work in the past. For the sake of improving the language.

 

My guess is that that line of code is one of the vestiges of Flex or Actionscript integration in ColdFusion. For example, take a look at Actionscript's mx.utils package. You can see there that toArray() is a method in the ArrayUtil class.

 

Which gives us a clue. Flex Remoting has officially been retired from ColdFusion as of ColdFusion 2018, and Flex Integratio....

 

To cut a long story short, just use the documented method, valueArray().

 

 

 

 

 

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
Explorer ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

And so we did (as written above).

Thanks for your elaboration. Unfortunately I made a mistake when creating the post in the first hand.

The broken old syntax has no ambiguity to functions, it was query[columname].toArray().

Where this came from in the first hand I do not know, our application had a number of developers in the past.

We changed all occurences of this syntax to ValueList and now everything seems to work.

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 ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

Ah, thanks for the addition. The code,

 

 

<cfset myQueryColumnArray=myQuery["myColumn"].toArray()>

 

 

fares better. The part myQuery["myColumn"] is correct CFML code. It will give you the data in myColumn in the first row of the myQuery result-set.

 

However, toArray is still out of place. For the reason I gave before: possibly because your predecessors used legacy Flex/Actionscript.

 

Even if we ignore the legacy argument, we will still have trouble using toArray. For, suppose the data-type of myColumn is int. Then myQuery["myColumn"] will belong to the class java.lang.Integer. ( You can verify this by dumping myQuery["myColumn"].getClass().getName() ). If myColumn is varchar type, representing email, for example, then myQuery["myColumn"] will belong to the class java.lang.String. If it's a date, the corresponding class will be java.util.Date.

 

If you examine the API of the classes java.lang.Integer and java.util.Date, you will find no method that returns an array. In the java.lang.String API, the only methods that return an array are getBytes(), split() and toCharArray(). None of them does what we expect toArray() to do. We therefore have to conclude that toArray() is probably not CFML, which would explain why it fails in ColdFusion 2018.

 

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
Explorer ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

I do not want to discuss that this is bad style at all. And also that our code probably only worked by chance.
Nevertheless I think that from installing a Coldfusion update previously working code should not break.
Each update to a higher Coldfusion version is a lot of work as our application is old. And this is plannable. But a security hotfix should not make code changes necessary. This is my opinion.

But thanks a lot for explaining and answering to my post!

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 ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

You have a point, @elisabethf82215657 . I hope Adobe will take note.

 

They could, for example, adopt a policy of only introducing "breaking changes" during a major or minor version release. Not during a patch. In fact, I had presumed they do that already, using some form of semantic versioning.

[What I mean by

major upgrade: CF11 to CF2016 or CF2018 to CF2021;

minor upgrade: CF2018.0.x to CF2018.1.x;

patch: CF2018.0.11 to CF2018.0.12;]

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 ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

Oh, come to think of it, don't give up hope just yet. I have created  a bug report. Let's see what Adobe does with it.

BKBK_2-1632928466681.png

 

BKBK_1-1632928437396.png

 

BKBK_0-1632928399257.png

 

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 ,
Sep 30, 2021 Sep 30, 2021

Copy link to clipboard

Copied

@elisabethf82215657 , guess what. Adobe has marked the ticket "To Fix". 🙂

You could add your vote to the ticket to give it a nudge.

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
Explorer ,
Oct 01, 2021 Oct 01, 2021

Copy link to clipboard

Copied

LATEST

I will do that! Thank you!

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