Skip to content

Commit

Permalink
dev/core#1143 Ensure that columns that are reserved words e.g. groupi…
Browse files Browse the repository at this point in the history
…ng are quoted for use in MySQL 8 when creating the view generation queries
  • Loading branch information
seamuslee001 committed Jan 3, 2020
1 parent e80b17e commit 8928896
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CRM/Core/I18n/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,17 @@ private static function createViewQuery($locale, $table, &$dao, $class = 'CRM_Co
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}";
Expand Down

0 comments on commit 8928896

Please sign in to comment.