I recently saw the following message on the cfml slack.
Don’t use columnlist if you need to worry about the column order. Use the query’s metadata.
I was caught off guard by this statement because I had some tests regarding query column ordering in one of my open projects that were passing. Checking the tests, I was worried because the columns were already in alphabetical order. I changed the order of the columns in the query, but the test still passed.
TryCF.com to the rescue!
I figured this might be an engine-specific bug. TryCF lets me test this on multiple environments without setting them each up on my system.
Looks like ACF decides that sorting your column names is helpful, while Lucee respects the order you provided. If your code needs to be cross-platform, you can, like Adam Cameron suggested, use the query metadata. Here’s an example:
You could use
ArrayMap (or, even better,
getMetadata(data).map(...)) if you are on Lucee or ACF 11, but this example was about better cross platform compatibility.
The Wrap Up
Going forward, I look forward to the day when CommandBox has built in servers for ACF. It will make testing cross-platform libraries a lot easier. Until then, a good CI strategy (like cfml-ci) will have to do.