Bug 31843 - Stock rotations do not allow rotas with the same name
Summary: Stock rotations do not allow rotas with the same name
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords: Academy
Depends on:
Blocks:
 
Reported: 2022-10-17 10:49 UTC by Pedro Amorim
Modified: 2022-11-11 09:33 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Amorim 2022-10-17 10:49:07 UTC
Steps to reproduce:
* Enable StockRotation system preference
* Tools > Stock rotation > New rota
* Enter name "rota", save.
* Create new rota, enter name "rota" again.
* Nasty plack error

This error also occurs when updating a rota's name to an already existing rota's name.

plack-intranet-error.log:
[WARN] DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Duplicate entry 'rota' for key 'stockrotationrotas_title' at /kohadevbox/koha/Koha/Object.pm line 170


> describe stockrotationrotas;
+-------------+--------------+------+-----+---------+----------------+
| Field       | Type         | Null | Key | Default | Extra          |
+-------------+--------------+------+-----+---------+----------------+
| rota_id     | int(11)      | NO   | PRI | NULL    | auto_increment |
| title       | varchar(100) | NO   | UNI | NULL    |                |
| description | text         | NO   |     | NULL    |                |
| cyclical    | tinyint(1)   | NO   |     | 0       |                |
| active      | tinyint(1)   | NO   |     | 0       |                |
+-------------+--------------+------+-----+---------+----------------+

Seems that the title is set as unique in the database and is causing this.