From 8928896f0918265fde6b15c398d3181251deabed Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 4 Jan 2020 07:58:54 +1100 Subject: [PATCH] dev/core#1143 Ensure that columns that are reserved words e.g. grouping are quoted for use in MySQL 8 when creating the view generation queries --- CRM/Core/I18n/Schema.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/I18n/Schema.php b/CRM/Core/I18n/Schema.php index 7f6a291811..13318083bb 100644 --- a/CRM/Core/I18n/Schema.php +++ b/CRM/Core/I18n/Schema.php @@ -487,17 +487,17 @@ class CRM_Core_I18n_Schema { if (!in_array($dao->Field, array_keys($columns[$table])) and !preg_match('/_[a-z][a-z]_[A-Z][A-Z]$/', $dao->Field) ) { - $cols[] = $dao->Field; + $cols[] = '`' . $dao->Field . '`'; } $tableCols[] = $dao->Field; } // view intrernationalized columns through an alias foreach ($columns[$table] as $column => $_) { if (!$isUpgradeMode) { - $cols[] = "{$column}_{$locale} {$column}"; + $cols[] = "`{$column}_{$locale}` `{$column}`"; } elseif (in_array("{$column}_{$locale}", $tableCols)) { - $cols[] = "{$column}_{$locale} {$column}"; + $cols[] = "`{$column}_{$locale}` `{$column}`"; } } return "CREATE OR REPLACE VIEW {$table}_{$locale} AS SELECT " . implode(', ', $cols) . " FROM {$table}"; -- 2.25.1