Hello Hamish, Sam, Stig, and other DataList afficionados :)
I've noticed two bugfixes due to misunderstanding how DataList works:
In general, it seems to be fairly arbitrary when DataList returns a clone,
and when it does inline modifications - which I think is very harmful to the API,
as it requires this "insider knowledge" from every dev.
$dataList->filter('Name', 'Bilbo'); // won't work, since its not assigned to new instance
$newList = $dataList->filter('Name', 'Bilbo'); // correct usage
$dataList->addFilter(array('Name' => 'Bilbo')); works, since it doesn't clone
The idea is that any state modification to the list produces a new list, correct?
In this case, the following methods should do that:
- join()
- limit()
- sort()
- addFilter()
- exclude()
- innerJoin()
- leftJoin()
- reverse()
There's a couple which do this already:
- filter()
- subtract()
That's a pretty major API change though. Hopefully I'm just misunderstanding the problem?
Ingo