query map() member function return new query, rather than modifying existing

Description

I have started a conversation here
http://lang.lucee.org/t/query-map/238

Given an array of structs, I can map to an array of boolean. Should a query map function be able to return a query with different columns, as with previous example, a query with one column containing true or false.

If I had a query with 'name' and 'data of birth', should map() be able to return a query with those two columns plus 'age'?

each() could most likely be used an solve these examples, but was just wonder if map() should work this way.

Activity

Show:

Zac Spitzer 9 June 2023 at 16:40

Zac Spitzer 6 May 2023 at 15:01

acf have implemented this

Michael Offner 13 June 2016 at 06:23

ACF12 also returns a new query, so for compatibility reasons (also to older Lucee versions) we need to keep this.

Brad Wood 14 October 2015 at 18:06

Set to public consultation since there's already this thread going on lang discourse: http://lang.lucee.org/t/query-map-allow-mapping-to-add-remove-columns-on-the-query/238

Sean Corfield 12 October 2015 at 16:39

Since a map operation should never update the original / source data structure (by convention: if you want to modify the original, use each instead), the only way to produce a different shaped query would be for the mapped function to be allowed to produce structs with different columns than the original. That's why I support this enhancement.

Anything that modifies the original data structure should be done with eachmap should always produce a new data structure with the original left untouched.

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Affects versions

Priority

Created 12 October 2015 at 07:09
Updated 9 June 2023 at 16:40
Resolved 9 June 2023 at 16:38