_find_by_unique_key - bugfix1/head
commit1a33f01390b8bd9948ce471cf92a2fd2f6cbfbf4
authorDmitriy Samborskiy <samborsky_d@yahoo.com>
Wed, 5 Aug 2015 09:05:10 +0000 (5 12:05 +0300)
committerDmitriy Samborskiy <samborsky_d@yahoo.com>
Wed, 5 Aug 2015 09:05:10 +0000 (5 12:05 +0300)
tree79a8e031a2a6b815864966ffd6e1f2392bc6c038
parent6505669a5055563a64e8308718be023d4b60ad53
_find_by_unique_key - bugfix

There was a wrong order of the argument binding.
Both the orders of the fields of the unique key: (1)
in the SQL statement and (2) in $dbd->bind_param() were
determined by the simple hash key iteration.

This accidentally worked with some old Perl versions but
with Perl v.5.18 (Ubuntu 14.04 LTS) it is not working anymore.

As a result, during the saving of RichSeq into the BioSQL database
`term` entries were sometimes not found by its unique key.
It led to the automatical creation of duplicated entries in the
`term` table. This, in its turn, lead to a crash later, when
the search by name or ontology_id brought several rows whereas just
one is expected. The unique key of the table:

UNIQUE KEY `name` (`name`,`ontology_id`, `is_obsolete`)

did not prevent the duplications because `is_obsolete` is always
NULL (it seems that this field is itself obsolete) and, since
SQL standard assumes NULL is not equal NULL, the duplications
are "unique" do not violate the constraint.

In order to resolve this issuet the sorting was added so that
the two argument orders were always the same.
lib/Bio/DB/BioSQL/BaseDriver.pm
lib/Bio/DB/BioSQL/BasePersistenceAdaptor.pm
lib/Bio/DB/BioSQL/Oracle/SpeciesAdaptorDriver.pm
lib/Bio/DB/BioSQL/Pg/SpeciesAdaptorDriver.pm
lib/Bio/DB/BioSQL/mysql/SpeciesAdaptorDriver.pm