dev/core#1143 Ensure that columns that are reserved words e.g. grouping are quoted...
authorSeamus Lee <seamuslee001@gmail.com>
Fri, 3 Jan 2020 20:58:54 +0000 (07:58 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Fri, 3 Jan 2020 20:58:54 +0000 (07:58 +1100)
CRM/Core/I18n/Schema.php

index 7f6a2918118f519bd94e08daa4b298b2cea5e456..13318083bbd0667edceda50045fa9d71e048f2a8 100644 (file)
@@ -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}";