As discussed in #koha, I think we are not using DBIC as well as we could. Right now we are only using it to replace hand written SQL queries. I would propose the following:

1) Allow find and simple searches in pl.
2) If a search is used more than once, it should be a ResultSet method
3) If a subroutine operates on a single table row, it should be a Result method
4) If a subroutine operates on a single table, it should be a ResultSet method
5) Any operation that works on tables linked by key constraints should take advantage of those DBIC relationships and also

In this way we can do things like:
$borrower->is_debarred
or
$borrower->has_overdues
orĀ 
@borrowers = $borrower->guarantees()

Any search can be a method in the ResultSet such as
$borrower->issue()->overdue_issues();
or
my @records_with_holds = $schema->resultset('Biblio')->with_holds()

I think in the long run this will make or code far more readable, testable, and efficient.

What do you think?

Kyle

http://www.kylehall.info
ByWater Solutions ( http://bywatersolutions.com )
Meadville Public Library ( http://www.meadvillelibrary.org )
Crawford County Federated Library System ( http://www.ccfls.org )
Mill Run Technology Solutions ( http://millruntech.com )