| Summary: | C4::Serial SQL possible collision on subscription.subscriptionid and subscriptionhistory.subscriptionid | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Chris Hall <chrish> |
| Component: | Serials | Assignee: | Bugs List <koha-bugs> |
| Status: | NEW --- | QA Contact: | |
| Severity: | minor | ||
| Priority: | P5 - low | CC: | chrish, colin.campbell |
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: |
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27964 https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=37569 |
||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
When looking at the table structure for subscriptions for a migration I realized that you always need to set all the tables in order to have a working and adjustable subscription: subscription, subsriptionhistory and also a first serial - I wonder if this wouldn't be more of a data issue? |
In C4::serials a few queries use queries of the form SELECT subscription.*, subscriptionhistory.* FROM subscription LEFT JOIN subscriptionhisotry USING(subscriptionid) If there are is a subscription without a matching subscriptionhistory then this join results in subscription.subscriptionid | subscriptionhistory.subscriptionid ---------------------------------------------------------------- 1234 | NULL Once this is fetched and squashed in to a hashref (for example, via fetchall_arrayref) this will be { subscriptionid => undef } This implicitly requires that every subscription has a matching subscriptionhistory. If we change the subscriptionhistory.* to select only the parts we need then we can avoid this issue. For SearchSubscription (which is only used by serials/serials-search.pl) none of the columns from subscriptionhistory appear to be used. We could also add a 'subscription.subscriptionid' to the end of the select, but this seems less clean.