I've come across something that looks like a bug t...
# lucee
d
I've come across something that looks like a bug to me. When I use the
queryFilter()
functionality it's altering the datatype of my columns in subtle ways that affects the use of
columnData()
. For example:
Copy code
<cfscript>
ids = queryNew("id", "varchar", [["0001"], ["2"], ["003"], ["0000004"], ["5"]]);

dump(ids.columnData("id"));
dump(ids.filter((row) => true).columnData("id"));
dump(queryFilter(ids, (row) => true).columnData("id"));
</cfscript>
In this case it's changing the string data to numeric values. So instead of getting back
['0001', '2', '003', '0000004', '5']
I get
[1, 2, 3, 4, 5]
. You can see an example of it on TryCF. It behaves this way in Lucee 5 and 6. Is this related to LDEV-3445?
a
Same issue with mapping too, eg:
dump(ids.map((row)=>row).columnData("id"))
Here's a more portable repro: https://trycf.com/gist/29b86a1b664e47a7ab2a6470393996ef/acf2021?theme=monokai CF does not have this issue.
columnData
is a red herring here. Well it's demonstrating a symptom, but it's not part of the problem.
d
@Adam Cameron thanks for jumping in that you think it's an issue too. Currently, I'm working around it using
valueList(ids.id).listToArray()
but that's certainly not ideal. However, eh
valueList()
works correctly (but
valueArray()
does not).
a
Yeah I noticed that when I was first converting your code to be portable so I could see what CF was doing. It's worrying that
valueList
and
valueArray
are clearly not doing the same thing under there hood, with just the final return value being changed.
z
maybe that's why they those two are deprecated
i think what's possibly going on is filter is creating a new query without meta data which then determines the type based on the content
anyhow file a specific bug
c
Curious what "deprecated" actually means in the Lucee project ( referring to your note above that
valueList
and
valueArray
are deprecated). While I appreciate that
QueryColumnData
is the recommended approach for Lucee (which returns an array like
valueArray
), the
valueList
and
valueArray
are not deprecated in ACF and will need to be kept in perpetuity for compatibility. As such, they should also work correctly, and match the functionality of ACF.
z
if people wanna fix bugs, PRs are welcome
c
I looked at the docs, Zac, which is how I learned
QueryColumnData
is the recommended approach. I'm asking why the previous functions are "deprecated" - which in common parlance would indicate that they are no longer supported and might be removed in a future version. So again, what does "deprecated" mean in the context of Lucee?
z
click the link
✅ 1
😉
i know not every one is a java dev, but what can really help with these improvements is writing up test cases as we are all cfml devs, I'm both (tho i always say i'm not a java dev) I usually spend 4x the time writing up test cases as the actual fix
and most of my work on lucee is unpaid
d
@zackster Thanks for responding. I created the issue: https://luceeserver.atlassian.net/browse/LDEV-4665 It would look like the issue is that the
QueryImpl()
call needs a list of the datatypes passed in. I may have some cycles later in the week and if so I'll try to put out a patch for this.
👍 2
c
I'd be happy to contribute test cases, although Dan has already got the gists (pun intended) of what needs to be added within the issue.