Ok, I am getting this weird error in Lucee 6 where...
# lucee
s
Ok, I am getting this weird error in Lucee 6 where when I duplicate() a query, then delete rows from the copy, it clears out the actual data in the original query object, but doesn't delete the rows (this worked fine in Lucee 5 and this is a simplified version without all the other logic we have as part of paginating a screen through a chached query, which now deletes all the data from the cached query after the first page) https://trycf.com/gist/d5cd6d417be790347afa8bb46085e1d3/lucee6?theme=monokai try that in Lucee 5 and compare to Lucee 6...Is there any solution to get 6 to work like 5 did?
My guess is that there is a bug in the duplicate() function in Lucee 6 where it is passing the query object by value, but the actual data in the cells by reference.
where the member function deleteRow() is affecting the original query.... I also tried using queryDeleteRow(), but that did the same thing
c
a workaround might be to do QofQ to filter the rows from the original query. something like this https://trycf.com/gist/c1bf023485f5765f42ea1989744b0efd/lucee6?theme=monokai
👍🏻 1
d
As a workaround, instead of using duplicate() you could use QoQ to return a new query or use queryNew() to build a non-referenced query. You could also serialize/deserialize, but if your query data is large the performance of that will probably be very poor.
☝️ 1
👍🏻 1
s
Thanks guys, that seems to work. I will adjust the code to be more like:
Copy code
<cfscript>
myOriginalQuery = queryNew("id,value", "integer,varchar");

for (i = 1; i <= 10; i++) {
	queryAddRow(myOriginalQuery);
	querySetCell(myOriginalQuery, "id", i, i);
	querySetCell(myOriginalQuery, "value", "Value " & i, i);
}


qofq = queryExecute("
    select *
    from myOriginalQuery
    where currentRow between 3 and 5 /* filter out the rows you don't want */
    ", {
    }, {
        dbtype: "query"
    });

writedump(var=myOriginalQuery, label="myOriginalQuery");
dump(var=qofq, label="query of queries");
</cfscript>
👍 1
r
I'm late to this, but don't forget about queryFilter() as an option. Or not, my brain isn't fully functioning yet this morning.
s
queryfilter works good too. but I did notice that the documentation for QueryFilter() is wrong (on both ACF documentation and Lucee documentation).... I'll post that in the documenation channel to to get the docs updated.
lol... actually docs are fine, I was just mis-reading them
Any of you guys know if either of those work arounds (queryfilter or just doing the query of queries) is more efficient?
I see some posts from a couple blogs indicating some negligable performance differences
but they are from 2019 so who knows if that stands today
I'm going to go ahead and not worry about it
QoQ is working and performing fine so I will leave that alone, but I will now remember queryFilter for the future 🙂... I definitely don't think of that one much
I just don't want to be stuck into just doing things a certain way because that's how I usually do it if there is a more efficient way.., but sometimes there are multiple ways to do the same thing and it is just a matter of preference.
r
Yeah, they both will work. I just put it out there as an option. QueryFilter() is especially nice when you have to filter on multiple pieces of complex criteria.
s
yeah, I can see that... I think I actually like the way queryFilter() makes me feel better... I have been moving towards trying to use member functions more. I'm probably going to do it like this:
Copy code
filteredQuery=myOriginalQuery.Filter(function(rowData,RowNumber){
  return arguments.RowNumber >=3 and arguments.RowNumber <=5;
})
r
Yep, then you can method chain as well.
👍🏻 1
s
honestly I feel like I don't even need this function in our code... it is basically just a function used on various ajax calls that paginate through cached query results. This function was written before there were queryFilter() qery.Filter() functions and I feel like it is not really adding any value in the applicaition. I may end up refactoring all of this to get rid of this utility function.
now that the funciton is just basically doing what filter can do
😆 1
c
cool! i didn't realize
slice()
was available for queries. it's even documented https://docs.lucee.org/reference/objects/query.html
r
Yeah. I saw the documentation thread posted on it earlier. I didn't know it was a thing either.
s
yeah... I'm going to be doing a review of all various member functions again so I can see if there is anything else I am missing
r