Skip to content
Snippets Groups Projects
Commit 415477a1 authored by PavelBegunkov's avatar PavelBegunkov
Browse files

Fix 'sp ChangeModuleName' incorrect response after updating name with identical value.

Merge branch 'super-improvements'
parent 66222334
Branches
Tags
No related merge requests found
......@@ -1257,12 +1257,25 @@ CREATE FUNCTION ChangeModuleName (
) RETURNS int(11)
BEGIN
DECLARE vDisciplineID INT DEFAULT -1;
SET vDisciplineID = (SELECT DisciplineID FROM modules WHERE ID = pModuleID LIMIT 1);
DECLARE vAlreadySameName BOOL DEFAULT FALSE;
SET vDisciplineID = (SELECT DisciplineID FROM modules WHERE ID = pModuleID LIMIT 1);
IF InternalIsMapLocked(vDisciplineID) THEN
RETURN -1;
END IF;
# Bodging, strange row_count() behaviour in some cases.
# i.e. update 1 module row. In case it's new and old names are same, row_count value may be 0.
SET vAlreadySameName = EXISTS(
SELECT * FROM modules
WHERE modules.ID = pModuleID AND modules.Type = 'regular' AND modules.Name = pName
LIMIT 1
);
IF vAlreadySameName THEN
return 0;
END IF;
UPDATE modules
SET modules.Name = pName
WHERE modules.ID = pModuleID AND modules.Type = 'regular'
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment