Skip to content
Snippets Groups Projects
Verified Commit d8a2e7ae authored by Timm Fitschen's avatar Timm Fitschen
Browse files

WIP: String IDs

parent 50acb681
No related branches found
No related tags found
3 merge requests!17Release 6.0,!15External String IDs,!11DRAFT: file system cleanup
Pipeline #41730 passed with warnings
...@@ -6,6 +6,8 @@ DROP PROCEDURE IF EXISTS getInfo; ...@@ -6,6 +6,8 @@ DROP PROCEDURE IF EXISTS getInfo;
DROP PROCEDURE IF EXISTS getRole; DROP PROCEDURE IF EXISTS getRole;
DROP PROCEDURE IF EXISTS setPassword; DROP PROCEDURE IF EXISTS setPassword;
DROP PROCEDURE IF EXISTS initAutoIncrement; DROP PROCEDURE IF EXISTS initAutoIncrement;
DELETE FROM name_data WHERE entity_id=50;
DELETE FROM entities WHERE id=50;
DELETE FROM entities WHERE id=99; DELETE FROM entities WHERE id=99;
...@@ -16,13 +18,13 @@ CREATE TABLE `entity_ids` ( ...@@ -16,13 +18,13 @@ CREATE TABLE `entity_ids` (
`internal_id` int(10) unsigned NOT NULL COMMENT 'Internal ID of an entity. This id is used internally in the *_data tables and elsewhere. This ID is never exposed via the CaosDB API.', `internal_id` int(10) unsigned NOT NULL COMMENT 'Internal ID of an entity. This id is used internally in the *_data tables and elsewhere. This ID is never exposed via the CaosDB API.',
PRIMARY KEY `entity_ids_pk` (`id`), PRIMARY KEY `entity_ids_pk` (`id`),
CONSTRAINT `entity_ids_internal_id` FOREIGN KEY (`internal_id`) REFERENCES `entities` (`id`) CONSTRAINT `entity_ids_internal_id` FOREIGN KEY (`internal_id`) REFERENCES `entities` (`id`)
) ENGINE=InnoDB; ) ENGINE=InnoDB COLLATE utf8mb4_bin;
-- fill all existing entities into the new entity_ids table. -- fill all existing entities into the new entity_ids table.
INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id>0 AND role!="DOMAIN" AND id!=50; INSERT INTO entity_ids (id, internal_id) SELECT id, id FROM entities WHERE id>0 AND role!="DOMAIN";
ALTER TABLE transaction_log MODIFY COLUMN `entity_id` VARCHAR(255) NOT NULL; ALTER TABLE transaction_log MODIFY COLUMN `entity_id` VARCHAR(255) COLLATE utf8mb4_bin NOT NULL;
ALTER TABLE user_info DROP CONSTRAINT `subjects_ibfk_1`; ALTER TABLE user_info DROP CONSTRAINT `subjects_ibfk_1`;
ALTER TABle user_info MODIFY COLUMN `entity` VARCHAR(255) DEFAULT NULL; ALTER TABle user_info MODIFY COLUMN `entity` VARCHAR(255) COLLATE utf8mb4_bin DEFAULT NULL;
ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KEY (`entity`) REFERENCES `entity_ids` (`id`); ALTER TABLE user_info ADD CONSTRAINT `subjects_ibfk_2` FOREIGN KEY (`entity`) REFERENCES `entity_ids` (`id`);
...@@ -62,7 +62,7 @@ BEGIN ...@@ -62,7 +62,7 @@ BEGIN
IF newipparent IS NULL THEN IF newipparent IS NULL THEN
-- throw error; -- throw error;
SELECT concat("This parent does not exists: ", Parent) SELECT concat("This parent does not exists: ", Parent)
FROM nonexisting; FROM parent_version_does_not_exist;
END IF; END IF;
END IF; END IF;
......
...@@ -1914,11 +1914,11 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','transaction_log','trans ...@@ -1914,11 +1914,11 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','transaction_log','trans
-- COLUMN transaction_log.entity_id -- COLUMN transaction_log.entity_id
SELECT tap.has_column('_caosdb_schema_unit_tests','transaction_log','entity_id',''); SELECT tap.has_column('_caosdb_schema_unit_tests','transaction_log','entity_id','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','transaction_log','entity_id','int(10) unsigned',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','transaction_log','entity_id','varchar(255)','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','transaction_log','entity_id','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','transaction_log','entity_id','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','transaction_log','entity_id',NULL,''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','transaction_log','entity_id',NULL,'');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','transaction_log','entity_id',NULL,''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','transaction_log','entity_id','utf8mb4','');
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','transaction_log','entity_id',NULL,''); SELECT tap.col_collation_is('_caosdb_schema_unit_tests','transaction_log','entity_id','utf8mb4_bin','');
-- COLUMN transaction_log.username -- COLUMN transaction_log.username
...@@ -2089,11 +2089,11 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','user_info','status','ut ...@@ -2089,11 +2089,11 @@ SELECT tap.col_collation_is('_caosdb_schema_unit_tests','user_info','status','ut
-- COLUMN user_info.entity -- COLUMN user_info.entity
SELECT tap.has_column('_caosdb_schema_unit_tests','user_info','entity',''); SELECT tap.has_column('_caosdb_schema_unit_tests','user_info','entity','');
SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','user_info','entity','int(10) unsigned',''); SELECT tap.col_column_type_is('_caosdb_schema_unit_tests','user_info','entity','varchar(255)','');
SELECT tap.col_extra_is('_caosdb_schema_unit_tests','user_info','entity','',''); SELECT tap.col_extra_is('_caosdb_schema_unit_tests','user_info','entity','','');
SELECT tap.col_default_is('_caosdb_schema_unit_tests','user_info','entity','NULL',''); SELECT tap.col_default_is('_caosdb_schema_unit_tests','user_info','entity','NULL','');
SELECT tap.col_charset_is('_caosdb_schema_unit_tests','user_info','entity',NULL,''); SELECT tap.col_charset_is('_caosdb_schema_unit_tests','user_info','entity','utf8mb4','');
SELECT tap.col_collation_is('_caosdb_schema_unit_tests','user_info','entity',NULL,''); SELECT tap.col_collation_is('_caosdb_schema_unit_tests','user_info','entity','utf8mb4_bin','');
-- INDEXES -- INDEXES
SELECT tap.indexes_are('_caosdb_schema_unit_tests','user_info','`subject_entity`',''); SELECT tap.indexes_are('_caosdb_schema_unit_tests','user_info','`subject_entity`','');
...@@ -2105,7 +2105,7 @@ SELECT tap.index_is_type('_caosdb_schema_unit_tests','user_info','subject_entity ...@@ -2105,7 +2105,7 @@ SELECT tap.index_is_type('_caosdb_schema_unit_tests','user_info','subject_entity
SELECT tap.is_indexed('_caosdb_schema_unit_tests','user_info','`entity`',''); SELECT tap.is_indexed('_caosdb_schema_unit_tests','user_info','`entity`','');
-- CONSTRAINTS -- CONSTRAINTS
SELECT tap.constraints_are('_caosdb_schema_unit_tests','user_info','`PRIMARY`,`subjects_ibfk_1`',''); SELECT tap.constraints_are('_caosdb_schema_unit_tests','user_info','`PRIMARY`,`subjects_ibfk_2`','');
-- CONSTRAINT user_info.PRIMARY -- CONSTRAINT user_info.PRIMARY
...@@ -2115,10 +2115,10 @@ SELECT tap.col_is_pk('_caosdb_schema_unit_tests','user_info','`realm`,`name`','' ...@@ -2115,10 +2115,10 @@ SELECT tap.col_is_pk('_caosdb_schema_unit_tests','user_info','`realm`,`name`',''
-- CONSTRAINT user_info.subjects_ibfk_1 -- CONSTRAINT user_info.subjects_ibfk_1
SELECT tap.has_constraint('_caosdb_schema_unit_tests','user_info','subjects_ibfk_1',''); SELECT tap.has_constraint('_caosdb_schema_unit_tests','user_info','subjects_ibfk_2','');
SELECT tap.constraint_type_is('_caosdb_schema_unit_tests','user_info','subjects_ibfk_1','FOREIGN KEY',''); SELECT tap.constraint_type_is('_caosdb_schema_unit_tests','user_info','subjects_ibfk_2','FOREIGN KEY','');
SELECT tap.fk_on_delete('_caosdb_schema_unit_tests','user_info','subjects_ibfk_1','RESTRICT',''); SELECT tap.fk_on_delete('_caosdb_schema_unit_tests','user_info','subjects_ibfk_2','RESTRICT','');
SELECT tap.fk_on_update('_caosdb_schema_unit_tests','user_info','subjects_ibfk_1','RESTRICT',''); SELECT tap.fk_on_update('_caosdb_schema_unit_tests','user_info','subjects_ibfk_2','RESTRICT','');
-- *************************************************************** -- ***************************************************************
-- TABLE _caosdb_schema_unit_tests.user_roles -- TABLE _caosdb_schema_unit_tests.user_roles
...@@ -2509,13 +2509,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getFileIdByPa ...@@ -2509,13 +2509,6 @@ SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','getFileIdByPa
SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getFileIdByPath','DEFINER',''); SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','getFileIdByPath','DEFINER','');
SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getFileIdByPath','CONTAINS SQL',''); SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','getFileIdByPath','CONTAINS SQL','');
-- PROCEDURES _caosdb_schema_unit_tests.initAutoIncrement
SELECT tap.has_procedure('_caosdb_schema_unit_tests','initAutoIncrement','');
SELECT tap.procedure_is_deterministic('_caosdb_schema_unit_tests','initAutoIncrement','NO','');
SELECT tap.procedure_security_type_is('_caosdb_schema_unit_tests','initAutoIncrement','DEFINER','');
SELECT tap.procedure_sql_data_access_is('_caosdb_schema_unit_tests','initAutoIncrement','CONTAINS SQL','');
-- PROCEDURES _caosdb_schema_unit_tests.initBackReference -- PROCEDURES _caosdb_schema_unit_tests.initBackReference
SELECT tap.has_procedure('_caosdb_schema_unit_tests','initBackReference',''); SELECT tap.has_procedure('_caosdb_schema_unit_tests','initBackReference','');
......
...@@ -37,9 +37,14 @@ INSERT INTO transactions (srid,seconds,nanos,username,realm) VALUES ...@@ -37,9 +37,14 @@ INSERT INTO transactions (srid,seconds,nanos,username,realm) VALUES
("SRIDbla", 1234, 2345, "me", "home"), ("SRIDbla", 1234, 2345, "me", "home"),
("SRIDblub", 2345, 3465, "me", "home"), ("SRIDblub", 2345, 3465, "me", "home"),
("SRIDblieb", 3456, 4576, "you", "home"); ("SRIDblieb", 3456, 4576, "you", "home");
SET @EntityID=99; SET @EntityID="99";
SET @PropertyID=11; SET @PropertyID=11;
SET @Value=50; SET @Value=50;
SET @SRID="SRIDbla";
call insertEntity(@EntityID, "TheName", "TheDesc", "RecordType", "{}");
call insertEntity(@Value, "RefValue", "ValueDesc", "Record", "{}");
SELECT internal_id INTO @InternalEntityID FROM entity_ids WHERE id = @EntityID;
SELECT internal_id INTO @InternalValueID FROM entity_ids WHERE id = @Value;
-- switch off versioning -- switch off versioning
DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING"; DELETE FROM feature_config WHERE _key = "ENTITY_VERSIONING";
...@@ -49,16 +54,16 @@ CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value, ...@@ -49,16 +54,16 @@ CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0); NULL, "FIX", NULL, NULL, NULL, NULL, 0);
-- TODO switch expected/actual -- TODO switch expected/actual
SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data; SELECT tap.eq("0", domain_id, "domain ok") FROM reference_data;
SELECT tap.eq(99, entity_id, "entity ok") FROM reference_data; SELECT tap.eq(@InternalEntityID, entity_id, "entity ok") FROM reference_data;
SELECT tap.eq(11, property_id, "property ok") FROM reference_data; SELECT tap.eq("11", property_id, "property ok") FROM reference_data;
SELECT tap.eq(50, value, "value ok") FROM reference_data; SELECT tap.eq(@InternalValueID, value, "value ok") FROM reference_data;
SELECT tap.eq("FIX", status, "status ok") FROM reference_data; SELECT tap.eq("FIX", status, "status ok") FROM reference_data;
SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data; SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data;
SELECT tap.eq(NULL, value_iversion, "value_iversion ok") FROM reference_data; SELECT tap.eq(NULL, value_iversion, "value_iversion ok 1") FROM reference_data;
-- clean up -- clean up
DELETE FROM reference_data WHERE domain_id=0 AND entity_id=99; DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalValueID;
-- ##################################################################### -- #####################################################################
-- TODO TEST insertEntityProperty with Versioning -- TODO TEST insertEntityProperty with Versioning
...@@ -69,39 +74,43 @@ INSERT INTO feature_config (_key, _value) VALUES ("ENTITY_VERSIONING", "ENABLED" ...@@ -69,39 +74,43 @@ INSERT INTO feature_config (_key, _value) VALUES ("ENTITY_VERSIONING", "ENABLED"
-- TEST insertEntityProperty with Versioning - REFERENCE HEAD -- TEST insertEntityProperty with Versioning - REFERENCE HEAD
SET @VALUE="50";
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value, CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0); NULL, "FIX", NULL, NULL, NULL, NULL, 0);
-- TODO switch expected/actual -- TODO switch expected/actual
SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data; SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data;
SELECT tap.eq(99, entity_id, "entity ok") FROM reference_data; SELECT tap.eq(@InternalEntityID, entity_id, "entity ok") FROM reference_data;
SELECT tap.eq(11, property_id, "property ok") FROM reference_data; SELECT tap.eq(11, property_id, "property ok") FROM reference_data;
SELECT tap.eq(50, value, "value ok") FROM reference_data; SELECT tap.eq(@InternalValueID, value, "value ok") FROM reference_data;
SELECT tap.eq("FIX", status, "status ok") FROM reference_data; SELECT tap.eq("FIX", status, "status ok") FROM reference_data;
SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data; SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data;
SELECT tap.eq(value_iversion, NULL, "value_iversion ok") FROM reference_data; SELECT tap.eq(value_iversion, NULL, "value_iversion ok 2") FROM reference_data;
DELETE FROM reference_data WHERE domain_id=0 AND entity_id=99; DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalEntityID;
-- TEST insertEntityProperty with Versioning - Reference version -- TEST insertEntityProperty with Versioning - Reference version
CALL insert_single_child_version(50, "hashbla", "versionbla", NULL, "SRIDbla"); SELECT * FROM entity_ids;
CALL insert_single_child_version(50, "hashblub", "versionblub", "versionbla", "SRIDblub"); SELECT * FROM entity_version;
SELECT e.version INTO @ParentVersion
SET @VALUE="50@versionbla"; FROM entity_version as e
WHERE e.entity_id = @InternalValueID
AND e._iversion = 1;
CALL insert_single_child_version(@InternalValueID, "hashblub", "versionblub", @ParentVersion, "SRIDblub");
SET @VALUE=CONCAT("50@", @ParentVersion);
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value, CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
NULL, "FIX", NULL, NULL, NULL, NULL, 0); NULL, "FIX", NULL, NULL, NULL, NULL, 0);
SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data; SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data;
SELECT tap.eq(99, entity_id, "entity ok") FROM reference_data; SELECT tap.eq(@InternalEntityID, entity_id, "entity ok") FROM reference_data;
SELECT tap.eq(11, property_id, "property ok") FROM reference_data; SELECT tap.eq(11, property_id, "property ok") FROM reference_data;
SELECT tap.eq(50, value, "value ok") FROM reference_data; SELECT tap.eq(@InternalValueID, value, "value ok") FROM reference_data;
SELECT tap.eq("FIX", status, "status ok") FROM reference_data; SELECT tap.eq("FIX", status, "status ok") FROM reference_data;
SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data; SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data;
SELECT tap.eq(value_iversion, "1", "value_iversion ok") FROM reference_data; SELECT tap.eq(value_iversion, "1", "value_iversion ok 3") FROM reference_data;
DELETE FROM reference_data WHERE domain_id=0 AND entity_id=99; DELETE FROM reference_data WHERE domain_id=0 AND entity_id=@InternalEntityID;
SET @VALUE="50@versionblub"; SET @VALUE="50@versionblub";
CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value, CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
...@@ -109,12 +118,12 @@ CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value, ...@@ -109,12 +118,12 @@ CALL insertEntityProperty(0, @EntityID, @PropertyID, "reference_data", @Value,
-- TODO switch expected/actual -- TODO switch expected/actual
SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data; SELECT tap.eq(0, domain_id, "domain ok") FROM reference_data;
SELECT tap.eq(99, entity_id, "entity ok") FROM reference_data; SELECT tap.eq(@InternalEntityID, entity_id, "entity ok") FROM reference_data;
SELECT tap.eq(11, property_id, "property ok") FROM reference_data; SELECT tap.eq(11, property_id, "property ok") FROM reference_data;
SELECT tap.eq(50, value, "value ok") FROM reference_data; SELECT tap.eq(@InternalValueID, value, "value ok") FROM reference_data;
SELECT tap.eq("FIX", status, "status ok") FROM reference_data; SELECT tap.eq("FIX", status, "status ok") FROM reference_data;
SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data; SELECT tap.eq("0", pidx, "pidx ok") FROM reference_data;
SELECT tap.eq(value_iversion, "2", "value_iversion ok") FROM reference_data; SELECT tap.eq(value_iversion, "2", "value_iversion ok 4") FROM reference_data;
-- invalid values throw errors -- invalid values throw errors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment