MDL-79397 reportbuilder: update reports to use auto-generated aliases.

We no longer need to be concerned about the manual setting of entity
table aliases (e.g. to avoid duplication between entities, or for using
a single entity multiple times), as it's handled transparently for us.
This commit is contained in:
Paul Holden 2023-09-15 11:28:30 +01:00
parent 7143cf4cbc
commit 3dec3fb8ce
No known key found for this signature in database
GPG key ID: A81A96D6045F6164
3 changed files with 17 additions and 22 deletions

View file

@ -68,17 +68,14 @@ class notes extends datasource {
ON {$recipientalias}.id = {$postalias}.userid")
);
// Join the user entity to represent the note author. Override all entity table aliases to avoid clash with first instance.
// Join the user entity to represent the note author.
$authorentity = (new user())
->set_entity_name('author')
->set_entity_title(new lang_string('author', 'core_notes'))
->set_table_aliases([
'user' => 'au',
'context' => 'auctx',
]);
->set_entity_title(new lang_string('author', 'core_notes'));
$authoralias = $authorentity->get_table_alias('user');
$this->add_entity($authorentity->add_join("
LEFT JOIN {user} au
ON au.id = {$postalias}.usermodified")
LEFT JOIN {user} {$authoralias}
ON {$authoralias}.id = {$postalias}.usermodified")
);
// Join the course entity for course notes.