Skip to content

Commit

Permalink
MDL-76900 roles: improve Oracle support for entity description column.
Browse files Browse the repository at this point in the history
Specifically during column grouping/aggregation, we need to avoid CLOB
datatype inconsistencies (ORA-00932).
  • Loading branch information
paulholden committed May 18, 2023
1 parent f500b2d commit 3894fa9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion admin/roles/classes/reportbuilder/local/entities/role.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function initialise(): base {
* @return column[]
*/
protected function get_all_columns(): array {
global $DB;

$contextalias = $this->get_table_alias('context');
$rolealias = $this->get_table_alias('role');

Expand Down Expand Up @@ -119,14 +121,19 @@ protected function get_all_columns(): array {
->set_is_sortable(true);

// Description column.
$descriptionfieldsql = "{$rolealias}.description";
if ($DB->get_dbfamily() === 'oracle') {
$descriptionfieldsql = $DB->sql_order_by_text($descriptionfieldsql, 1024);
}
$columns[] = (new column(
'description',
new lang_string('description'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_LONGTEXT)
->add_fields("{$rolealias}.description, {$rolealias}.shortname")
->add_field($descriptionfieldsql, 'description')
->add_field("{$rolealias}.shortname")
->set_callback(static function($description, stdClass $role): string {
if ($description === null) {
return '';
Expand Down

0 comments on commit 3894fa9

Please sign in to comment.