minor change in new-grid-update

parent 191f71c3
......@@ -35,17 +35,16 @@ BEGIN
END IF;
-- Carga las variables desde el JSON para free_category_coord e id_cat
IF _attributes->>"$.free_category_coord_x" = 'null' THEN
SET _free_category_coord_x = NULL;
ELSE
SELECT _attributes->>"$.free_category_coord_x" INTO _free_category_coord_x;
END IF;
IF _attributes->>"$._free_category_coord_y" = 'null' THEN
IF _attributes->>"$.free_category_coord_y" = 'null' THEN
SET _free_category_coord_y = NULL;
ELSE
SELECT _attributes->>"$._free_category_coord_y" INTO _free_category_coord_y;
SELECT _attributes->>"$.free_category_coord_y" INTO _free_category_coord_y;
END IF;
-- Esto hay que hacerlo porque el null procediente del JSON para id_cat lo reconoce como un literal
......@@ -55,16 +54,22 @@ BEGIN
SELECT _attributes->>"$.id_cat" INTO _id_cat;
END IF;
-- Ya no nos hacen falta estos atributos
UPDATE stu_picto
SET
`attributes` = JSON_REMOVE(`attributes`, '$.free_category_coord_x'),
`attributes` = JSON_REMOVE(`attributes`, '$.free_category_coord_y')
WHERE id = _id_stu_picto;
-- Pictogramas que estan en escenas sin categorias
IF (_free_category_coord_x IS NOT NULL) OR (_free_category_coord_y IS NOT NULL) THEN
-- Pasa las coordenadas libres a coord_x y coord_y, ademas elimina variables antiguas
UPDATE stu_picto_id_cat
UPDATE stu_picto
SET
`attributes` = JSON_REPLACE(`attributes`, '$.coord_x', _free_category_coord_x),
`attributes` = JSON_REPLACE(`attributes`, '$.coord_y', _free_category_coord_y),
`attributes` = JSON_REMOVE(`attributes`, '$.free_category_coord_x'),
`attributes` = JSON_REMOVE(`attributes`, '$.free_category_coord_y')
`attributes` = JSON_REMOVE(`attributes`, '$.id_cat')
WHERE id = _id_stu_picto;
-- Pictogramas que estan en escenas con categorias
......@@ -96,11 +101,6 @@ BEGIN
SET id_grid = _grid_id
WHERE id = _id_stu_picto;
-- Se pone id_cat a NULL, puesto que dicho valor no lo volveremos a necesitar
UPDATE stu_picto
SET
`attributes` = JSON_REMOVE(`attributes`, '$.id_cat')
WHERE id = _id_stu_picto;
END IF;
-- La escena no existe, la creo, la asocio con el picto padre y asocio el pictograma actual a dicha escena
......@@ -121,12 +121,6 @@ BEGIN
UPDATE stu_picto
SET id_grid = LID
WHERE id = _id_stu_picto;
-- Se pone id_cat a NULL, puesto que dicho valor no lo volveremos a necesitar
UPDATE stu_picto
SET
`attributes` = JSON_REMOVE(`attributes`, '$.id_cat')
WHERE id = _id_stu_picto;
END IF;
END IF;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment