Lucee 6.1.0.243 - duplicate() not making a deep copy

On Lucee 6.1.0.243 we’ve discovered that if we create a query object, then duplicate() it to make a deep copy, and then add rows to the copy, whilst the rows are not added to the original query (as expected), if you use querycolumndata() on original, you’ll see the array length has been increased by the additional rows added to the copy.

This is a regression from Lucee 5 where it does not occur and correct behavior is exhibited.

Try this code:

qry1 = querynew(“a,b,c”,“integer,integer,integer”);
queryaddrow(qry1);
querysetcell(qry1,“a”,1);
querysetcell(qry1,“b”,2);
querysetcell(qry1,“c”,3);
writedump(qry1);
writedump(querycolumndata(qry1,“a”));
qry2 = duplicate(qry1);
queryaddrow(qry2);
querysetcell(qry2,“a”,4);
querysetcell(qry2,“b”,5);
querysetcell(qry2,“c”,6);

writedump(qry1);
writedump(querycolumndata(qry1,“a”));

Notice we’re dumping qry1 at the end there, not qry2. You’ll see the result of querycolumndata() shows an additional array element has been added on the original query object.

incidentally, if using valuelist() (although deprecated in Lucee) on the original, after several iterations of adding rows to clones, you get an ArrayIndexOutOfBoundsException error.