[Bug 18862] New: Some DBIx relations from issues table do not seem to work
From report 17698: my @notes = Koha::Checkouts->search({ 'me.note' => { '!=', undef } }, {
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Bug ID: 18862 Summary: Some DBIx relations from issues table do not seem to work Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: m.de.rooy@rijksmuseum.nl QA Contact: testopia@bugs.koha-community.org prefetch => [ 'borrower', { item => 'biblionumber' } ] }); I am having problems on the template side. I can access the item and biblio information about the issue, but not the borrower information. [Internal server error triggered by AUTOLOAD in Koha::Object.] Additionally adding 'branch' will trigger a similar error. What is different with the item relation ?? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jonathan.druart@bugs.koha-c | |ommunity.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Aleisha Amohia <aleisha@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aleisha@catalyst.net.nz --- Comment #1 from Aleisha Amohia <aleisha@catalyst.net.nz> --- I think I have found another place where the DBIx relationships don't work as expected. See Bug 18870. I'm trying to use a prefetch to get data that the DBIx relationship should make easy to access, but for some reason it fails. I'm thinking this is a big issue that we need to get fixed, because otherwise the Koha Objects are essentially useless to us. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Aleisha Amohia <aleisha@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=17698 -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Aleisha Amohia <aleisha@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=18870 -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 --- Comment #2 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Found it: Issue.pm contains: sub item { my ( $self ) = @_; my $item_rs = $self->_result->item; return Koha::Item->_new_from_dbic( $item_rs ); } and sub patron { my ( $self ) = @_; my $patron_rs = $self->_result->borrower; return Koha::Patron->_new_from_dbic( $patron_rs ); } So we need to use patron instead of borrower. Instead of adding item, patron, branch etc. subs all over the place, we probably do better in checking these relations in the AUTOLOAD too. Will try something here. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Some DBIx relations from |Allow relations in |issues table do not seem to |Koha::Object's AUTOLOAD |work | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 --- Comment #3 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Well, this would probably work in AUTOLOAD: my @relations = $self->_result->relationships; if( grep { /^$method$/ } @relations ) { return _new_from_dbic( _guess_koha_class($method), $self->_result->$method ); } together with something like (maybe add check_install on the module): sub _guess_koha_class { my ( $self, $relation ) = @_; my $rel_startcase = uc(substr($relation,0,1)) . substr($relation,1); my $class_dbix = "Koha::Schema::Result::" . $rel_startcase; my $koha_class; if( $class_dbix->can('koha_objects_class') ) { $koha_class = $class_dbix->koha_objects_class; $koha_class =~ s/s$//; # singular $koha_class =~ s/ie$/y/; # Librarie => Library etc. } else { $koha_class = "Koha::" . $rel_startcase; } return $koha_class; } But I am afraid that it is not that optimal performance-wise.. -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 --- Comment #4 from Marcel de Rooy <m.de.rooy@rijksmuseum.nl> --- Any thoughts before closing this report? Jonathan? -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 --- Comment #5 from Jonathan Druart <jonathan.druart@bugs.koha-community.org> --- What you pasted in comment 2 is the current way to go. I am not in favour of adding more magic for now. We clearly see/show what we are using and the methods are covered by tests. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WORKSFORME -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=18862 Marcel de Rooy <m.de.rooy@rijksmuseum.nl> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org