https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=22569
--- Comment #48 from Martin Renvoize <martin.renvo...@ptfs-europe.com> --- (In reply to Jonathan Druart from comment #46) > 2. > - my ($datesent,$frombranch,$tobranch) = GetTransfers( $item->itemnumber > ); > + my $transfer = $item->get_transfer; > > This GetTransfers is pretty bad, it could return several transfers, but > callers are not ready for that: > opac/opac-detail.pl: my ( $transfertwhen, $transfertfrom, $transfertto ) > = GetTransfers($itm->{itemnumber}); > > > So that's definitely a good move to have a get_transfer method that will > return only 1, the current one. > However, cannot we enforce this constraint at DB level (DB unique key) and > have a ->find call in ->get_transfer to replace the ->first? Internally '->find' theoretically checks for constraints (Unique, Primary Key, etc).. if it doesn't find any, it falls back to search and throws an error if more than one row is found.. So in reality one would need to pass the order_by and rows attributes to get the correct single row.. So in effect they're the code results in the same thing... As for adding a unique constraint at the DB... I can't see what constraint would work here... We're looking for the first with 'datesent' OR if there isn't a sent one, then the oldest 'daterequested'.. -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list Koha-bugs@lists.koha-community.org https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/