We're updating the issue view to help you get more done. 

query.map mishandles the "template" query

Description

See http://blog.adamcameron.me/2017/04/cfml-lucee-13-v-4-14-v-6-coldfusion-we.html

Query.map and queryMap take a parameter of type query which specifies the definition of the query that should be returned. This is not uses properly in two ways, as demonstrated by this test case:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 describe("map tests", function(){ var numbers = duplicate(baseNumbers); var remapTemplate = queryNew("value,english,maori"); var reMapped = numbers.map(function(row){ return {value=row.id, english=row.en, maori=row.mi}; }, remapTemplate); it("does a basic remapping", function(){ var queryWithDifferentColumns = queryNew("value,english,maori", "integer,varchar,varchar", [ [1,"one","tahi"], [2,"two","rua"], [3,"three","toru"], [4,"four","wha"] ]); expect(reMapped).toBe(queryWithDifferentColumns); }); it("does not mess with the remapTemplate", function(){ expect(remapTemplate).toBe(queryNew("value,english,maori")); }); });

Both of these fail:

  • the columns from queryWithDifferentColumns should be the only columns in the resultant query. however these columns are just added to the original query

  • the queryWithDifferentColumns should not change: it's just a template. However it seems this is replaced by the remapped query.

Contrast this with CF on which both tests pass.

Environment

Status

Assignee

Michael Offner

Reporter

Adam Cameron

Sprint

None

Fix versions

Affects versions

5.1.4.18

Priority

Critical