Bug 18014: AddAuthority should respect AUTO_INCREMENT
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Mon, 30 Jan 2017 14:19:35 +0000 (15:19 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Tue, 14 Feb 2017 14:01:11 +0000 (14:01 +0000)
commitad38b24308df1cd3d451302d2ada3a4e59c45b62
treea9c0a394a40ae5d6c9b2ff9afcb30062d0f2ffb9
parent24ac8392b39ac82b528cb931e97c19c0e582fbf8
Bug 18014: AddAuthority should respect AUTO_INCREMENT

Instead of using the MAX(authid)+1 logic, AddAuthority should just save
the record and get the new id. The authid column is an autoincrement.

This eliminates problems where a newly assigned authid also refers to a
previously deleted record. (And it will not cause problems when refining
the dontmerge functionality on report 9988.)

Note: ModAuthority also calls AddAuthority to update an existing record; in
that case we should not create a new record even if the record should not
be found any more (which should be exceptional).

This patch also simplifies handling of 001 in the authority record: in all
cases this field is updated now; no need to check its contents.

Test plan:
[1] Run t/db_dependent/AuthoritiesMarc.t
[2] Add a new authority record via the interface

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/AuthoritiesMarc.pm
t/db_dependent/AuthoritiesMarc.t