From 1c54d9e00b64630db7683e4ec0d85d5c1058454e Mon Sep 17 00:00:00 2001 From: larssandergreen Date: Fri, 21 Oct 2022 13:43:55 -0600 Subject: [PATCH] add FROM DUAL for MariaDB --- CRM/Upgrade/Incremental/sql/README.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Upgrade/Incremental/sql/README.txt b/CRM/Upgrade/Incremental/sql/README.txt index ded7ef05a1..fb74e5aecc 100644 --- a/CRM/Upgrade/Incremental/sql/README.txt +++ b/CRM/Upgrade/Incremental/sql/README.txt @@ -82,7 +82,7 @@ VALUES If you are inserting an option value row that might already exist (for example, a Relative Date Filter could have already been added manually), we should only insert it if it doesn't already exist. -Here's an example which adds a Relative Date Filter with localization, the next available weight and does not insert if the value already exists. +Here's an example which adds a Relative Date Filter with localization, the next available weight and does not insert if the value already exists (FROM DUAL is required for MariaDB) ------------------------------------------------------------------------------ SELECT @option_group_id_date_filter := max(id) from civicrm_option_group where name = 'relative_date_filters'; @@ -91,6 +91,7 @@ INSERT INTO `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`, `icon`) SELECT @option_group_id_date_filter, {localize}'{ts escape="sql"}Previous 2 fiscal years{/ts}'{/localize}, 'previous_2.fiscal_year', 'previous_2.fiscal_year', NULL, NULL, 0, (SELECT @max_wt := @max_wt+1), {localize}NULL{/localize}, 0, 0, 1, NULL, NULL, NULL +FROM DUAL WHERE NOT EXISTS (SELECT * FROM civicrm_option_value WHERE `value`='previous_2.fiscal_year' AND `option_group_id` = @option_group_id_date_filter); ------------------------------------------------------------------------------ -- 2.25.1