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

@ -60,13 +60,13 @@ class categories extends datasource {
$this->add_entity($courseentity
->add_join("LEFT JOIN {course} {$coursealias} ON {$coursealias}.category = {$categoryalias}.id"));
// Join cohort entity (amend alias to avoid clash with course entity, indicate context table join alias).
// Join cohort entity (indicate context table join alias).
$cohortentity = (new cohort())
->set_table_alias('cohort', 'ch')
->set_table_join_alias('context', $contextalias);
$cohort = $cohortentity->get_table_alias('cohort');
$this->add_entity($cohortentity
->add_join($categoryentity->get_context_join())
->add_join("LEFT JOIN {cohort} ch ON ch.contextid = {$contextalias}.id"));
->add_join("LEFT JOIN {cohort} {$cohort} ON {$cohort}.contextid = {$contextalias}.id"));
// Join role entity.
$roleentity = (new role())