diff --git a/patches/patch20201110-3.0.0-rc3/patch.sh b/patches/patch20201110-3.0.0-rc3/patch.sh new file mode 100755 index 0000000000000000000000000000000000000000..2b737587b24508e1c2d5817ff26155b2636a5316 --- /dev/null +++ b/patches/patch20201110-3.0.0-rc3/patch.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# ** header v3.0 +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2018 Research Group Biomedical Physics, +# Max-Planck-Institute for Dynamics and Self-Organization Göttingen +# Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> +# Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# +# ** end header +# +# new entity_version table +# Update mysql schema to version v3.0.0-rc3 +NEW_VERSION="v3.0.0-rc3" +OLD_VERSION="v3.0.0-rc2" + +if [ -z "$UTILSPATH" ]; then + UTILSPATH="../utils" +fi + +. $UTILSPATH/patch_header.sh $* + + +check_version $OLD_VERSION + + +mysql_execute_file $PATCH_DIR/update_archive_isa.sql + + +update_version $NEW_VERSION + +success + diff --git a/patches/patch20201110-3.0.0-rc3/update_archive_isa.sql b/patches/patch20201110-3.0.0-rc3/update_archive_isa.sql new file mode 100644 index 0000000000000000000000000000000000000000..d256b76015ae2e7b5b2a510a8eca7cce21a82f93 --- /dev/null +++ b/patches/patch20201110-3.0.0-rc3/update_archive_isa.sql @@ -0,0 +1,24 @@ +/* + * This file is a part of the CaosDB Project. + * + * Copyright (C) 2020 IndiScale GmbH <info@indiscale.com> + * Copyright (C) 2020 Timm Fitschen <t.fitschen@indiscale.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +-- Create tables for versioning. + +ALTER TABLE archive_isa + ADD COLUMN `direct` BOOLEAN DEFAULT TRUE; diff --git a/procedures/deleteIsaCache.sql b/procedures/deleteIsaCache.sql index 4af004e5475ec9a82e6425f66ba389f92213c63d..1306b59e3df7dfdd46d44121d5e488170d358296 100644 --- a/procedures/deleteIsaCache.sql +++ b/procedures/deleteIsaCache.sql @@ -50,10 +50,10 @@ BEGIN FROM entity_version WHERE entity_id = EntityID; - -- move to archive_isa before deleting (only direct child-parent relations) - INSERT IGNORE INTO archive_isa (child, child_iversion, parent) + -- move to archive_isa before deleting + INSERT IGNORE INTO archive_isa (child, child_iversion, parent, direct) -- TODO copy rpath as well - SELECT e.child, IVersion AS child_iversion, e.parent + SELECT e.child, IVersion AS child_iversion, e.parent, rpath = EntityID FROM isa_cache AS e WHERE e.child = EntityID; END IF; diff --git a/procedures/retrieveEntityParents.sql b/procedures/retrieveEntityParents.sql index 16466fc991693766c1bfded1acdeec453e2cd655..fb5a176e867a48a83de0644466be3425164e7df8 100644 --- a/procedures/retrieveEntityParents.sql +++ b/procedures/retrieveEntityParents.sql @@ -78,18 +78,19 @@ retrieveEntityParentsBody: BEGIN SELECT i.parent AS ParentID, - ( SELECT value FROM archive_name_data + ( SELECT value FROM name_data WHERE domain_id = 0 AND entity_id = ParentID AND property_id = 20 - AND _iversion = IVersion) AS ParentName, + ) AS ParentName, -- This is not necessarily the name of the parent at the time of IVersion but it is a good guess. Future implementations of the archive_isa table should also store the IVersion of the parents. Only then the historically correct ParentName can be reconstructed. e.description AS ParentDescription, e.role AS ParentRole, (SELECT acl FROM entity_acl AS a WHERE a.id = e.acl) AS ACL FROM archive_isa AS i JOIN entities AS e ON (i.parent = e.id) WHERE i.child = EntityID - AND i.child_iversion = IVersion; + AND i.child_iversion = IVersion + AND i.direct IS TRUE; LEAVE retrieveEntityParentsBody; END IF; diff --git a/tests/test_autotap.sql b/tests/test_autotap.sql index 26af8b87fbf61e98ef34f0a2a6b37efb296452c1..91354b121761d08c5951cd702fef69fb6d0fbdf5 100644 --- a/tests/test_autotap.sql +++ b/tests/test_autotap.sql @@ -2539,13 +2539,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','entityACL','N SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','entityACL','DEFINER',''); SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','entityACL','CONTAINS SQL',''); --- PROCEDURES _caosdb_schema_unit_tests.finishNegationFilter - -SELECT tap.has_procedure('_caosdb_schema_unit_tests','finishNegationFilter',''); -SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','finishNegationFilter','NO',''); -SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','finishNegationFilter','DEFINER',''); -SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','finishNegationFilter','CONTAINS SQL',''); - -- PROCEDURES _caosdb_schema_unit_tests.finishSubProperty SELECT tap.has_procedure('_caosdb_schema_unit_tests','finishSubProperty',''); @@ -2595,27 +2588,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','initBackRefer SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','initBackReference','DEFINER',''); SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','initBackReference','CONTAINS SQL',''); --- PROCEDURES _caosdb_schema_unit_tests.initConjunctionFilter - -SELECT tap.has_procedure('_caosdb_schema_unit_tests','initConjunctionFilter',''); -SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','initConjunctionFilter','NO',''); -SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','initConjunctionFilter','DEFINER',''); -SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','initConjunctionFilter','CONTAINS SQL',''); - --- PROCEDURES _caosdb_schema_unit_tests.initDisjunctionFilter - -SELECT tap.has_procedure('_caosdb_schema_unit_tests','initDisjunctionFilter',''); -SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','initDisjunctionFilter','NO',''); -SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','initDisjunctionFilter','DEFINER',''); -SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','initDisjunctionFilter','CONTAINS SQL',''); - --- PROCEDURES _caosdb_schema_unit_tests.initNegationFilter - -SELECT tap.has_procedure('_caosdb_schema_unit_tests','initNegationFilter',''); -SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','initNegationFilter','NO',''); -SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','initNegationFilter','DEFINER',''); -SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','initNegationFilter','CONTAINS SQL',''); - -- PROCEDURES _caosdb_schema_unit_tests.initPOVRefidsTable SELECT tap.has_procedure('_caosdb_schema_unit_tests','initPOVRefidsTable','');