salix/db/versions/.archive/10459-chocolateMedeola/02-createFunctionMockTime.sql

23 lines
497 B
SQL

DROP FUNCTION IF EXISTS `util`.`mockTime`;
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `util`.`mockTime`()
RETURNS datetime
DETERMINISTIC
BEGIN
/**
* Returns the mockTime with predefined timezone or current dateTime
* depending of config.mockEnabled
*
* @return formatted datetime
*/
DECLARE vMockEnabled BOOL;
SELECT mockEnabled INTO vMockEnabled FROM config LIMIT 1;
IF vMockEnabled THEN
RETURN mockTimeBase(FALSE);
ELSE
RETURN util.NOW();
END IF;
END$$
DELIMITER ;