The dbic discard_changes method returns the current schema object ready for chaining.. for some reason we didn't wrap it to return the current Koha object when we do the same and as such we have to always call it in a distinct statement and we lose chainability. my $patron = Koha::Patron->new()->store()->discard_changes; This returns a Koah::Schema::Result::Borrower object.. it should return the fully updated from the database Koha::Patron object. Instead, one has to do my $patron = Koha::Patron->new()->store(); $patron->discard_changes; This is confusing and inconsistent with the parent library.
Love this. Been meaning to file this for ages.
Created attachment 173507 [details] [review] Bug 38273: Make Koha::Object->discard_changes chainable
Created attachment 173528 [details] [review] Bug 38273: Make Koha::Object->discard_changes chainable Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 173529 [details] [review] Bug 38273: Make sure same object is returned This patch adds a test to make sure the same object is returned. A code change is also added to make sure the tests pass. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 173538 [details] [review] Bug 38273: Make Koha::Object->discard_changes chainable Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 173539 [details] [review] Bug 38273: Make sure same object is returned This patch adds a test to make sure the same object is returned. A code change is also added to make sure the tests pass. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Blimey!.. This went through quick!.. nice one chaps.
(In reply to Martin Renvoize (ashimema) from comment #7) > Blimey!.. This went through quick!.. nice one chaps. Let's turn them all around that quickly :D
Pushed for 24.11! Well done everyone, thank you!
Created attachment 173705 [details] [review] Bug 38273: Adjust t/db_dependent/api/v1/holds.t
(In reply to Pedro Amorim from comment #10) > Created attachment 173705 [details] [review] [review] > Bug 38273: Adjust t/db_dependent/api/v1/holds.t Good catch!
Follow-up pushed to main, fingers crossed! Thanks, Pedro!
Failing tests on 24.05.x with this patch set applied. No backport.