tracker issue : CF-4022420

select a category, or use search below
(searches all categories and all time range)
Title:

make queries implement an array interface

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 07/18/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final / CF2018U5

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 25

Full detail: http://blog.adamcameron.me/2015/07/cfml-suggestion-make-queries-implement.html

TL;DR:

Implement these:

Query.append(): adds a row to the end of a query, or concatenates two queries together.
Query.clear(): does the query equivalent of TRUNCATE TABLE in SQL.
Query.deleteAt(): removes row(s?) from the query.
Query.insertAt(): sticks 'em back in again. These two operations are possible with QoQ, but not pretty.
Query.each(): essential. I can't believe ColdFusion does not have this yet (Lucee does).
Query.slice(): copies rows from within a query.
Query.len(): I'd put this in anyhow, even if one can use recordCount: it's such a ubiquitous function for collections.
Query.filter(): removes rows from the query based on the filter rules.
Query.map(): should already have been implemented.
Query.new(): already got it. Well, not as a method. It would be good to have an OO way of creating a query though, without falling back to queryNew().
Query.prepend(): adds rows (/another query) to the front of a query.
Query.reduce(): should already have been implemented.
Query.set(): possibly use .filter() and .insertAt() instead?
Query.sort(): sorts the query.
Query.find(): possibly. Although would be better placed to use .filter() or .reduce(), perhaps?
Query.reverse(): reverses order of row. Although achievable via .reduceRight()
Query.swap(): swaps specified rows.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4022420

External Customer Info:
External Company:  
External Customer Name: Adam
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Oh, and these: Query.every(Function): returns true if all rows in the query fulfills the test. ALl collections should have this method. Query.filter(String): where String is an SQL WHERE clause, and query and clause are passed to the QoQ engine. Maybe call this Query.where() instead? Is there further scope for Query.select(), Query.join(), Query.groupBy(), Query.orderBy() too? Query.reduceRight(): all collections should have this method. Same as .reduce(), but starts from the last element, not the first. Query.some(Function): returns true if a row in the query fulfills the test defined by the callback. All collections should have this method.
Comment by External U.
6569 | July 18, 2015 03:53:10 AM GMT
+1.............................................
Vote by External U.
6576 | July 18, 2015 04:39:27 PM GMT
+1........................
Vote by External U.
6577 | July 18, 2015 09:25:24 PM GMT
+1111111111111111111111111
Vote by External U.
6578 | July 19, 2015 02:18:40 PM GMT
Please explain in 25 characters or more how this feature impacts productivity and why you are adding a vote.
Vote by External U.
6579 | July 19, 2015 02:32:41 PM GMT
Please explain in 25 characters or more how this feature impacts productivity and why you are adding a vote.
Vote by External U.
6580 | July 20, 2015 12:55:39 PM GMT
+1 .............................. .............................. ..............................
Vote by External U.
6581 | July 21, 2015 04:28:21 AM GMT
please please please please please please
Vote by External U.
6582 | July 21, 2015 01:33:12 PM GMT
+1. And to finish out my 25 characters: Please see the original description in the ticket. Adam does a good job of explaining the why. I'd hate to simply rehash his ticket.
Vote by External U.
6583 | July 23, 2015 11:40:38 PM GMT
Please definitely share the results of your investigation here and any forward-moving plan you arrive at. Cheers. And thanks for considering this.
Comment by External U.
6570 | September 05, 2015 01:37:46 AM GMT
This would be a very handy enhancement gets my vote
Vote by External U.
6584 | September 05, 2015 02:45:24 PM GMT
+1!!!! I'd like to put 2 votes on this one
Vote by External U.
6585 | September 05, 2015 11:29:50 PM GMT
Adobe, Please include the additional votes from the comments here: http://blog.adamcameron.me/2015/07/cfml-suggestion-make-queries-implement.html Thanks!, -Aaron
Comment by External U.
6571 | September 05, 2015 11:44:14 PM GMT
+1 many many many many use cases
Vote by External U.
6586 | October 14, 2015 12:50:00 PM GMT
Yes!!! DO THIS!!......................
Vote by External U.
6587 | October 14, 2015 01:01:49 PM GMT
For the iterator methods, the query object should be treated like an array of structs, i.e: [{id:1,name="bob"},{id:2,name="jill"}]. I would also suggest adding a "returnType" argument to the map function so that the query can be iterated and transformed, then return an array of structs. Options would be query(default) or array - both would return a *NEW* instance and not modify the original.
Comment by External U.
6572 | October 14, 2015 01:04:05 PM GMT
Noooo!!! .map() returns the same type of object, with the same rows, just with each row "remapped". .reduce() handles changing data types. These things are pretty well prescribed in standard usage of these kinds of methods. Please... don't let this be *another instance* of CFML not quite understanding what it's supposed to be doing (ref: the short-hand ?: operator which was implemented wrong).
Comment by External U.
6573 | October 14, 2015 02:55:06 PM GMT
As Adam has explained in his blog post, queries are a fundamental data structure in CFML. Member functions that allow one to efficiently and simply work with queries would be VERY useful!
Vote by External U.
6588 | December 10, 2015 03:12:59 PM GMT
Right, so Adobe, you've had about five months to "investigate". What were your findings? This would be a really excellent (and not too tricky?) language feature to add to CF2016.
Comment by External U.
6574 | December 10, 2015 03:40:00 PM GMT
Definitely some solid stuff here!
Vote by External U.
6589 | December 11, 2015 07:32:42 AM GMT
+1 for enhancing queries. Would love to see some of the additional functions Lucee has added and mentioned on Adam's blog posting.
Vote by External U.
6590 | December 11, 2015 07:42:17 AM GMT
You have got ++ on this
Vote by External U.
6591 | December 11, 2015 03:50:25 PM GMT
+1 This would be wonderfully powerful to have added to the CF ecosystem. Endless possibilities :)
Vote by External U.
6592 | December 12, 2015 09:30:43 AM GMT
That sounds very useful. Do it.
Vote by External U.
6593 | December 12, 2015 10:05:27 AM GMT
Please explain in 25 characters or more how this feature impacts productivity and why you are adding a vote
Vote by External U.
6594 | December 12, 2015 12:07:12 PM GMT
Voting because all of these proposed methods would be handy to use with queries. Is that 25 words? I don't know... no counter or anything but I guess that's probably about 26 words by now. Let's see...
Vote by External U.
6595 | December 12, 2015 08:53:35 PM GMT
Can you please confirm in what version of ColdFusion this is going to be implemented in. It says "to fix" but does not say which version.
Comment by External U.
6575 | January 25, 2016 08:18:23 AM GMT
We have implemented this enhancement. This will be added as part of an upcoming update of ColdFusion 2018. Here's the list of functions that we have implemented: recordCount() len() clear() append() prepend() swap() slice() reverse() insertAt() deleteAt() some() every()   -Nimit
Comment by Nimit S.
31127 | August 18, 2019 05:48:55 PM GMT