Looks like there is a new bug introduced with the ...
# adobe
p
Looks like there is a new bug introduced with the latest ColdFusion patches for 2021/2023.
Query[ "Column Name" ].toString()
returns the internal name of the specific column and row of the query, instead of the data inside it. Switching to CF2018 or Lucee on TryCF shows the expected behavior... https://trycf.com/gist/8daf55ac44a1e2d6fe8b06c4fa7ca28e/acf2021?theme=monokai
I added a bug to the tracker, but still figuring out a decent workaround...
m
I would normally do Query['Column Name'][CurrentRow] to get that value
or that if you want to scope currentRow Query['Column Name'][Query.CurrentRow]
👍 3
p
I was going to try that and hadn't had a chance... It does fix the issue, so I'll change my code to that. It's still a bug, so hopefully they will fix it.
m
Can I get the tracker ID @Patrick S? Adding for visibility: @nimitsharma @priyank_adobe
👍 1
p
The tracker ID is: CF-4224422
a
This is not a bug, we have indeed fixed the behaviour, kindly go through the following tracker issue for the details around it https://tracker.adobe.com/#/view/CF-4219387, we need to give the currentRow now to get to the actual column value and then invoke the corresponding toString() method on it
The reason is that until you give the currentRow it doesn't extracts a value on which we can apply the toString() , because Query['Column Name'] returns a QueryColumn type . Earlier it was automatically converting it, but there was an issue that was logged and we fixed it
g
Come on, be realistic though, this change is super dangerous
🎯 1
👍 1
👀 1
d
I'm sorry, this isn't clear to me:
*So now you have to specify the index to fetch the elements* such as news.title[1], news.title[2] and Bug is fixed for all functions used on an implicitly-referenced 1st row.
I REALLY HOPE that implicit references to the first row aren't broken now. That would break a lot of code that's worked for years, as others have said. Is the question about direct references to the query column with no row number, function calls on that, or both?
r
Unpopular opinion probably, but I agree with Adobe on this. It was an "undocumented feature" and its use was lazy and dangerous. However, it should have probably been done with a version change or have a flag to revert behavior, if possible.
d
Has anyone dug up something in some docs that explicitly says a row number is or isn't required to access data in the first row? If I had to bet, I'd say it's super likely there are official examples in many places that reference the first row with no row number. It's a tricky thing to search for.
m
@Dave Merrill I've just tested this and you can still access the first row implicitly outside of a query loop if using dot notation to dereference the column. This is specifically about using the array notation, which doesn't seem to have ever worked in ACF. Hence the need for
toString
after. FYI, that functionality of returning the value in that case seems to be new to CF2018 and I'd be surprised if it was documented.
d
Thanks for checking. By "array notation" do you mean query[columnName] with no row number? I'd consider that a weird hybrid construct that I don't think is likely in our code. That's my concern, two big apps built over decades by many people, with varying degrees of anality. Anything that changes fundamental language features is scary,
m
Yes, that is what I mean by array notation. The example Patrick said was having an issue is
Query[ "Column Name" ].toString()
d
Yeah I'd call that weird, personally. Bottom line, so far our apps aren't going down in flames, knock silicon, and the last comment in the referenced ticked was 12/11/2023, plenty of time to know if we really had a problem.
👍 1
m
To be clear, the issue of not returning the value also occurs with the dot notation when using
toString()
(or certain other functions as shown in that ticket).
p
My usage came about when I needed to reference the column names dynamically originally, so at its simplest I was switching from
<cfoutput query="myQuery"><p>#myQuery.ColumnName#</p></cfoutput>
to
<cfoutput query="myQuery"><p>#myQuery[ ColumnName ].toString()#</p></cfoutput>
. To be fair, I was pretty mystified by why
#myQuery[ "ColumnName" ]#
breaks inside the CFOUTPUT/CFLOOP query, but not in a CFDUMP which outputs as a string or when outputting just the first row outside of... I get why it could be considered a bug, but at the same time, it has been the regular behavior for many years - and more similarly matches the ancient behavior of CFML's CFOUTPUT and CFLOOP's handling of query column variables over the years, which 'automagically' handle the row numbers. Additionally, CF-4219387 doesn't appear to be listed in the bugs fixed for update 15, 16 or 17 in CF2021: https://helpx.adobe.com/coldfusion/kb/coldfusion-2021-update-17.html#bugfix
As a bonus, CFDUMP still behaves the old way on 2021 and 2023, and automagically outputs the current column's row's data and not the internal column/row name or a structure with the internal name and the contents: https://trycf.com/gist/9c872ec8bab1c5d85489dc000162b5ef/acf2021?theme=monokai
m
According to the tracker, CF-4219387 was never "fixed". It was withdrawn as designed.
p
It isn't clear which of the bug fixes changed the behavior, CF-4217594 seems to be the closest.
d
(I hate when they mark tickets as "withdrawn" when that's blatantly not the case)
m
Well, CF2023 does still return "NO" with their example. What they "fixed" was make sure that CF2021 was consistent with CF2023 (and versions prior to CF2018). Since technically that seems to be the opposite of what was being requested, it's probably correct to say that the ticket was not "fixed".