Nick
09/26/2023, 9:36 PM.isEmpty()
on an empty string in a query result returns NO
. It had returned YES
in CF 2021 and CF 2018. I would expect it to return YES
. It returns YES
outside of a query result, for example, with a string or a string value in a struct. Is there a setting for this, or is it a bug? https://trycf.com/gist/0d6b615a9fb1783169826f69b86a7f57/acf2023?theme=monokaiseancorfield
<cfscript>
news = queryNew(
"id,title",
"integer,varchar",
[ {"id":1,"title":""} ]
);
writeDump(news.title[1].isEmpty());
</cfscript>
A slight change to your code, adding the explicit row index, and it returns YES
as expected.Nick
09/26/2023, 9:43 PMDave Merrill
09/26/2023, 9:50 PMMark Takata (Adobe)
09/26/2023, 9:53 PMseancorfield
Nick
09/26/2023, 10:03 PMchris_hopkins
09/27/2023, 8:18 AMRodney
09/27/2023, 12:33 PMNick
09/27/2023, 1:33 PMisEmpty()
the headless function is Lucee-only. I was referring to a string member function someString.isEmpty()
. But now that I'm looking, technically this may be an undocumented feature. I don't see it in Adobe's docs. Only the .isEmpty()
member function for arrayIsEmpty()
and structIsEmpty()
is documented. But, I've used it for years (since CF11 at least) to check if the value of a string variable is an empty string.hemi345
09/27/2023, 1:33 PMI thought it was an official thing/feature/supposed to work that way that if you didn't specify a row a query should always return the first row.
Same, I have a ton of legacy code that does this.Dave Merrill
09/27/2023, 1:34 PMDave Merrill
09/27/2023, 1:39 PMDave Merrill
09/27/2023, 1:42 PMNick
09/27/2023, 1:45 PMisEmpty()
is Lucee only. But the member function .isEmpty()
works in both.
I think tryCF is having issues with Lucee5 at the moment, at least on my end. Nothing works. Happens occasionally on tryCF.Dave Merrill
09/27/2023, 3:32 PMnews.title.isEmpty()
.
All versions return YES for news.title[1].isEmpty()
.
All versions return the correct value for news.title
and news.title[1]
.
Upshot is that the issue appears to be only with isEmpty(), not query column references with no row number in general.
So yay.Nick
09/27/2023, 3:44 PMnews.title.isEmpty()
wasn't working as expected. But the issue remains that it regressed in 2023, as it was working in 2018 and 2021. Also, I haven't tested all valid member functions against fields in the implicitly referenced 1st row of a query result, so it's possible other member functions are affected as well.Rodney
09/27/2023, 3:51 PMDave Merrill
09/27/2023, 5:11 PMNick
09/27/2023, 5:24 PM.isEmpty()
is a Java function in the String
class, so you may be spot on. Considering it works on strings in CF, maybe the problem is not that it should work as a native CF method, but that CF is incorrectly data-typing news.title
when the row number is unspecified.Dave Merrill
09/27/2023, 5:26 PMNick
09/27/2023, 5:27 PMDave Merrill
09/27/2023, 5:31 PM