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

BUG: replacement ids interfering with external ids.

parent 65f34f84
No related branches found
No related tags found
2 merge requests!21F mariadb 48,!11DRAFT: file system cleanup
Pipeline #42670 passed
...@@ -28,16 +28,16 @@ DELIMITER // ...@@ -28,16 +28,16 @@ DELIMITER //
* ---------- * ----------
* PropertyID : VARCHAR(255) * PropertyID : VARCHAR(255)
* The property id. * The property id.
* DataType : VARCHAR(255) * DataTypeID : VARCHAR(255)
* The data type, e.g. "DOUBLE", "Person" * The data type id (not the name!)
*/ */
CREATE PROCEDURE db_5_0.insertEntityDataType(in PropertyID VARCHAR(255), in DataType VARCHAR(255)) CREATE PROCEDURE db_5_0.insertEntityDataType(in PropertyID VARCHAR(255), in DataTypeID VARCHAR(255))
BEGIN BEGIN
DECLARE InternalPropertyID INT UNSIGNED DEFAULT NULL; DECLARE InternalPropertyID INT UNSIGNED DEFAULT NULL;
SELECT internal_id INTO InternalPropertyID FROM entity_ids WHERE id=PropertyID; SELECT internal_id INTO InternalPropertyID FROM entity_ids WHERE id=PropertyID;
INSERT INTO data_type (domain_id, entity_id, property_id, datatype) SELECT 0, 0, InternalPropertyID, ( SELECT entity_id FROM name_data WHERE domain_id = 0 AND property_id = 20 AND value = DataType LIMIT 1); INSERT INTO data_type (domain_id, entity_id, property_id, datatype) SELECT 0, 0, InternalPropertyID, ( SELECT internal_id FROM entity_ids WHERE id = DataTypeID);
END; END;
......
...@@ -76,9 +76,20 @@ BEGIN ...@@ -76,9 +76,20 @@ BEGIN
DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL; DECLARE InternalEntityID INT UNSIGNED DEFAULT NULL;
DECLARE InternalDomainID INT UNSIGNED DEFAULT 0; DECLARE InternalDomainID INT UNSIGNED DEFAULT 0;
SELECT temp.internal_id INTO InternalDomainID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = DomainID UNION SELECT DomainID AS internal_id) AS temp LIMIT 1; SELECT internal_id INTO InternalDomainID FROM entity_ids WHERE id = DomainID;
SELECT temp.internal_id INTO InternalEntityID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1; -- When DomainID != 0 the EntityID could possibly be a 'replacement id'
SELECT temp.internal_id INTO InternalPropertyID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = PropertyID UNION SELECT PropertyID AS internal_id) AS temp LIMIT 1; -- which are internal ids by definition (and do not have external
-- equivalents).
IF LOCATE("$", EntityID) = 1 THEN
SET InternalEntityID=SUBSTRING(EntityID, 2);
ELSE
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
IF LOCATE("$", PropertyID) = 1 THEN
SET InternalPropertyID=SUBSTRING(PropertyID, 2);
ELSE
SELECT internal_id INTO InternalPropertyID FROM entity_ids WHERE id = PropertyID;
END IF;
CASE Datatable CASE Datatable
WHEN 'double_data' THEN WHEN 'double_data' THEN
...@@ -109,8 +120,10 @@ BEGIN ...@@ -109,8 +120,10 @@ BEGIN
SELECT 0 from `ReferenceValueIVersion_WAS_NULL`; SELECT 0 from `ReferenceValueIVersion_WAS_NULL`;
END IF; END IF;
ELSEIF LOCATE("$", PropertyValue) = 1 THEN
SET ReferenceValue = SUBSTRING(PropertyValue, 2);
ELSE ELSE
SELECT temp.internal_id INTO ReferenceValue FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = PropertyValue UNION SELECT PropertyValue AS internal_id) AS temp LIMIT 1; SELECT internal_id INTO ReferenceValue FROM entity_ids WHERE id = PropertyValue;
END IF; END IF;
......
...@@ -36,7 +36,7 @@ BEGIN ...@@ -36,7 +36,7 @@ BEGIN
SET ED = ED + 1; SET ED = ED + 1;
END WHILE; END WHILE;
SELECT e.id as ReplacementID FROM entities AS e WHERE e.Role='_REPLACEMENT' and e.id!=0; SELECT CONCAT("$", e.id) as ReplacementID FROM entities AS e WHERE e.Role='_REPLACEMENT' and e.id!=0;
END; END;
// //
......
...@@ -42,8 +42,9 @@ drop procedure if exists db_5_0.retrieveEntity // ...@@ -42,8 +42,9 @@ drop procedure if exists db_5_0.retrieveEntity //
* *
* ResultSet * ResultSet
* --------- * ---------
* Tuple of (Datatype, Collection, EntityID, EntityName, EntityDesc, * Tuple of (DatatypeID, DatatypeName, Collection, EntityID, EntityName,
* EntityRole, FileSize, FilePath, FileHash, ACL, Version) * EntityDesc, EntityRole, FileSize, FilePath, FileHash, ACL,
* Version)
*/ */
create procedure db_5_0.retrieveEntity( create procedure db_5_0.retrieveEntity(
in EntityID VARCHAR(255), in EntityID VARCHAR(255),
...@@ -52,7 +53,8 @@ retrieveEntityBody: BEGIN ...@@ -52,7 +53,8 @@ retrieveEntityBody: BEGIN
DECLARE FilePath VARCHAR(255) DEFAULT NULL; DECLARE FilePath VARCHAR(255) DEFAULT NULL;
DECLARE FileSize VARCHAR(255) DEFAULT NULL; DECLARE FileSize VARCHAR(255) DEFAULT NULL;
DECLARE FileHash VARCHAR(255) DEFAULT NULL; DECLARE FileHash VARCHAR(255) DEFAULT NULL;
DECLARE DatatypeID INT UNSIGNED DEFAULT NULL; DECLARE DatatypeID VARCHAR(255) DEFAULT NULL;
DECLARE InternalDatatypeID INT UNSIGNED DEFAULT NULL;
DECLARE CollectionName VARCHAR(255) DEFAULT NULL; DECLARE CollectionName VARCHAR(255) DEFAULT NULL;
DECLARE IsHead BOOLEAN DEFAULT TRUE; DECLARE IsHead BOOLEAN DEFAULT TRUE;
DECLARE IVersion INT UNSIGNED DEFAULT NULL; DECLARE IVersion INT UNSIGNED DEFAULT NULL;
...@@ -94,7 +96,7 @@ retrieveEntityBody: BEGIN ...@@ -94,7 +96,7 @@ retrieveEntityBody: BEGIN
LIMIT 1; LIMIT 1;
SELECT datatype SELECT datatype
INTO DatatypeID INTO InternalDatatypeID
FROM archive_data_type FROM archive_data_type
WHERE domain_id = 0 WHERE domain_id = 0
AND entity_id = 0 AND entity_id = 0
...@@ -116,10 +118,10 @@ retrieveEntityBody: BEGIN ...@@ -116,10 +118,10 @@ retrieveEntityBody: BEGIN
( SELECT value FROM ( SELECT value FROM
( SELECT value FROM name_data ( SELECT value FROM name_data
WHERE domain_id = 0 WHERE domain_id = 0
AND entity_ID = DatatypeID AND entity_id = InternalDatatypeID
AND property_id = 20 AND property_id = 20
UNION SELECT DatatypeID AS value ) AS tmp LIMIT 1 ) AS DatatypeName,
) AS tmp LIMIT 1 ) AS Datatype, ( SELECT id FROM entity_ids WHERE internal_id=InternalDatatypeID ) AS DatatypeID,
CollectionName AS Collection, CollectionName AS Collection,
EntityID AS EntityID, EntityID AS EntityID,
( SELECT value FROM archive_name_data ( SELECT value FROM archive_name_data
...@@ -152,7 +154,7 @@ retrieveEntityBody: BEGIN ...@@ -152,7 +154,7 @@ retrieveEntityBody: BEGIN
WHERE file_id = InternalEntityID WHERE file_id = InternalEntityID
LIMIT 1; LIMIT 1;
SELECT dt.datatype INTO DatatypeID SELECT dt.datatype INTO InternalDatatypeID
FROM data_type as dt FROM data_type as dt
WHERE dt.domain_id=0 WHERE dt.domain_id=0
AND dt.entity_id=0 AND dt.entity_id=0
...@@ -169,8 +171,9 @@ retrieveEntityBody: BEGIN ...@@ -169,8 +171,9 @@ retrieveEntityBody: BEGIN
SELECT SELECT
( SELECT value FROM name_data ( SELECT value FROM name_data
WHERE domain_id = 0 WHERE domain_id = 0
AND entity_id = DatatypeID AND entity_id = InternalDatatypeID
AND property_id = 20 LIMIT 1 ) AS Datatype, AND property_id = 20 LIMIT 1 ) AS DatatypeName,
( SELECT id FROM entity_ids WHERE internal_id=InternalDatatypeID ) AS DatatypeID,
CollectionName AS Collection, CollectionName AS Collection,
EntityID AS EntityID, EntityID AS EntityID,
( SELECT value FROM name_data ( SELECT value FROM name_data
......
...@@ -41,7 +41,8 @@ delimiter // ...@@ -41,7 +41,8 @@ delimiter //
* collection_override, # e.g. LIST * collection_override, # e.g. LIST
* name_override, # the name * name_override, # the name
* desc_override, # the description * desc_override, # the description
* type_override, # the datatype, e.g. DOUBLE * type_name_override, # the datatype, e.g. DOUBLE
* type_id_override, # data type id.
* entity_id, # same as input EntityID * entity_id, # same as input EntityID
* InternalPropertyID, # internal property id, to be used when property_id * InternalPropertyID, # internal property id, to be used when property_id
* # is NULL because a replacement is used. * # is NULL because a replacement is used.
...@@ -60,11 +61,12 @@ retrieveOverridesBody: BEGIN ...@@ -60,11 +61,12 @@ retrieveOverridesBody: BEGIN
-- When DomainID != 0 the EntityID could possibly be a 'replacement id' -- When DomainID != 0 the EntityID could possibly be a 'replacement id'
-- which are internal ids by definition (and do not have external -- which are internal ids by definition (and do not have external
-- equivalents). That's why we do the UNION here, falling back to the -- equivalents).
-- EntityID. IF LOCATE("$", EntityID) = 1 THEN
SELECT temp.internal_id INTO InternalEntityID SET InternalEntityID=SUBSTRING(EntityID, 2);
FROM (SELECT internal_id AS internal_id FROM ELSE
entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1; SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
-- DomainID != 0 are always normal (i.e. external) Entity ids. -- DomainID != 0 are always normal (i.e. external) Entity ids.
SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID; SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID;
...@@ -94,9 +96,10 @@ retrieveOverridesBody: BEGIN ...@@ -94,9 +96,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
name AS name_override, name AS name_override,
NULL AS desc_override, NULL AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_name_overrides FROM archive_name_overrides
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -110,9 +113,10 @@ retrieveOverridesBody: BEGIN ...@@ -110,9 +113,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
NULL AS name_override, NULL AS name_override,
description AS desc_override, description AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_desc_overrides FROM archive_desc_overrides
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -126,13 +130,14 @@ retrieveOverridesBody: BEGIN ...@@ -126,13 +130,14 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
NULL AS name_override, NULL AS name_override,
NULL AS desc_override, NULL AS desc_override,
IFNULL((SELECT value FROM name_data (SELECT value FROM name_data
WHERE domain_id = 0 WHERE domain_id = 0
AND entity_id = datatype AND entity_id = datatype
AND property_id = 20 AND property_id = 20
LIMIT 1), datatype) AS type_override, LIMIT 1) AS type_name_override,
(SELECT id FROM entity_ids WHERE internal_id = datatype) AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_data_type FROM archive_data_type
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -146,9 +151,10 @@ retrieveOverridesBody: BEGIN ...@@ -146,9 +151,10 @@ retrieveOverridesBody: BEGIN
collection AS collection_override, collection AS collection_override,
NULL AS name_override, NULL AS name_override,
NULL AS desc_override, NULL AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM archive_collection_type FROM archive_collection_type
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -163,9 +169,10 @@ retrieveOverridesBody: BEGIN ...@@ -163,9 +169,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
name AS name_override, name AS name_override,
NULL AS desc_override, NULL AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM name_overrides FROM name_overrides
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -177,9 +184,10 @@ retrieveOverridesBody: BEGIN ...@@ -177,9 +184,10 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
NULL AS name_override, NULL AS name_override,
description AS desc_override, description AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM desc_overrides FROM desc_overrides
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -191,12 +199,13 @@ retrieveOverridesBody: BEGIN ...@@ -191,12 +199,13 @@ retrieveOverridesBody: BEGIN
NULL AS collection_override, NULL AS collection_override,
NULL AS name_override, NULL AS name_override,
NULL AS desc_override, NULL AS desc_override,
IFNULL((SELECT value FROM name_data (SELECT value FROM name_data
WHERE domain_id = 0 WHERE domain_id = 0
AND entity_ID = datatype AND entity_ID = datatype
AND property_id = 20 LIMIT 1), datatype) AS type_override, AND property_id = 20 LIMIT 1) AS type_name_override,
(SELECT id FROM entity_ids WHERE internal_id = datatype) AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM data_type FROM data_type
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
...@@ -208,9 +217,10 @@ retrieveOverridesBody: BEGIN ...@@ -208,9 +217,10 @@ retrieveOverridesBody: BEGIN
collection AS collection_override, collection AS collection_override,
NULL AS name_override, NULL AS name_override,
NULL AS desc_override, NULL AS desc_override,
NULL AS type_override, NULL AS type_name_override,
NULL AS type_id_override,
EntityID AS entity_id, EntityID AS entity_id,
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS property_id
FROM collection_type FROM collection_type
WHERE domain_id = InternalDomainID WHERE domain_id = InternalDomainID
......
...@@ -66,9 +66,12 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -66,9 +66,12 @@ retrieveEntityPropertiesBody: BEGIN
-- When DomainID != 0 the EntityID could possibly be a 'replacement id' -- When DomainID != 0 the EntityID could possibly be a 'replacement id'
-- which are internal ids by definition (and do not have external -- which are internal ids by definition (and do not have external
-- equivalents). That's why we do the UNION here, falling back to the -- equivalents).
-- EntityID. IF LOCATE("$", EntityID) = 1 THEN
SELECT temp.internal_id INTO InternalEntityID FROM (SELECT internal_id AS internal_id FROM entity_ids WHERE id = EntityID UNION SELECT EntityID AS internal_id) AS temp LIMIT 1; SET InternalEntityID=SUBSTRING(EntityID, 2);
ELSE
SELECT internal_id INTO InternalEntityID FROM entity_ids WHERE id = EntityID;
END IF;
-- DomainID != 0 are always normal (i.e. external) Entity ids. -- DomainID != 0 are always normal (i.e. external) Entity ids.
SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID; SELECT internal_id INTO InternalDomainID from entity_ids WHERE id = DomainID;
...@@ -95,7 +98,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -95,7 +98,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- double properties #-- double properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -109,7 +112,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -109,7 +112,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- integer properties #-- integer properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -123,7 +126,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -123,7 +126,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- date properties #-- date properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, '.NULL.NULL') AS PropertyValue, CONCAT(value, '.NULL.NULL') AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -137,7 +140,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -137,7 +140,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- datetime properties #-- datetime properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns)) CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns))
AS PropertyValue, AS PropertyValue,
...@@ -152,7 +155,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -152,7 +155,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- text properties #-- text properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -166,7 +169,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -166,7 +169,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- enum properties #-- enum properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -180,11 +183,11 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -180,11 +183,11 @@ retrieveEntityPropertiesBody: BEGIN
#-- reference properties #-- reference properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
IF(value_iversion IS NULL, IF(value_iversion IS NULL,
IF(status = "REPLACEMENT", IF(status = "REPLACEMENT",
value, CONCAT("$", value),
( SELECT id FROM entity_ids WHERE internal_id = value )), ( SELECT id FROM entity_ids WHERE internal_id = value )),
-- make it "value@version" if necessary -- make it "value@version" if necessary
CONCAT( CONCAT(
...@@ -202,7 +205,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -202,7 +205,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- null properties #-- null properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
NULL AS PropertyValue, NULL AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -216,7 +219,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -216,7 +219,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- name properties #-- name properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -233,7 +236,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -233,7 +236,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- double properties #-- double properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -246,7 +249,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -246,7 +249,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- integer properties #-- integer properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -259,7 +262,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -259,7 +262,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- date properties #-- date properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, '.NULL.NULL') AS PropertyValue, CONCAT(value, '.NULL.NULL') AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -272,7 +275,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -272,7 +275,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- datetime properties #-- datetime properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns)) CONCAT(value, 'UTC', IF(value_ns IS NULL, '', value_ns))
AS PropertyValue, AS PropertyValue,
...@@ -286,7 +289,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -286,7 +289,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- text properties #-- text properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -299,7 +302,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -299,7 +302,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- enum properties #-- enum properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -312,11 +315,11 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -312,11 +315,11 @@ retrieveEntityPropertiesBody: BEGIN
#-- reference properties #-- reference properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
IF(value_iversion IS NULL, IF(value_iversion IS NULL,
IF(status = "REPLACEMENT", IF(status = "REPLACEMENT",
value, CONCAT("$", value),
( SELECT id FROM entity_ids WHERE internal_id = value )), ( SELECT id FROM entity_ids WHERE internal_id = value )),
-- make it "value@version" if necessary -- make it "value@version" if necessary
CONCAT( CONCAT(
...@@ -333,7 +336,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -333,7 +336,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- null properties #-- null properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
NULL AS PropertyValue, NULL AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
...@@ -346,7 +349,7 @@ retrieveEntityPropertiesBody: BEGIN ...@@ -346,7 +349,7 @@ retrieveEntityPropertiesBody: BEGIN
#-- name properties #-- name properties
SELECT SELECT
property_id AS InternalPropertyID, CONCAT("$", property_id) AS InternalPropertyID,
( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID, ( SELECT id FROM entity_ids WHERE internal_id = property_id ) AS PropertyID,
value AS PropertyValue, value AS PropertyValue,
status AS PropertyStatus, status AS PropertyStatus,
......
...@@ -35,7 +35,7 @@ CREATE PROCEDURE db_5_0.updateEntity( ...@@ -35,7 +35,7 @@ CREATE PROCEDURE db_5_0.updateEntity(
in EntityName VARCHAR(255), in EntityName VARCHAR(255),
in EntityDescription TEXT, in EntityDescription TEXT,
in EntityRole VARCHAR(255), in EntityRole VARCHAR(255),
in Datatype VARCHAR(255), in DatatypeID VARCHAR(255),
in Collection VARCHAR(255), in Collection VARCHAR(255),
in ACL VARBINARY(65525)) in ACL VARBINARY(65525))
BEGIN BEGIN
...@@ -114,11 +114,10 @@ BEGIN ...@@ -114,11 +114,10 @@ BEGIN
DELETE FROM collection_type DELETE FROM collection_type
WHERE domain_id=0 AND entity_id=0 AND property_id=InternalEntityID; WHERE domain_id=0 AND entity_id=0 AND property_id=InternalEntityID;
IF Datatype IS NOT NULL THEN IF DatatypeID IS NOT NULL THEN
INSERT INTO data_type (domain_id, entity_id, property_id, datatype) INSERT INTO data_type (domain_id, entity_id, property_id, datatype)
SELECT 0, 0, InternalEntityID, SELECT 0, 0, InternalEntityID,
( SELECT entity_id FROM name_data WHERE domain_id = 0 ( SELECT internal_id FROM entity_ids WHERE id = DatatypeID );
AND property_id = 20 AND value = Datatype LIMIT 1 );
IF Collection IS NOT NULL THEN IF Collection IS NOT NULL THEN
INSERT INTO collection_type (domain_id, entity_id, property_id, INSERT INTO collection_type (domain_id, entity_id, property_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment