From b6372d1cca64e265f4a1e964edc7fae16cf9c6a3 Mon Sep 17 00:00:00 2001
From: s j <sj@1729.be>
Date: Sat, 12 Oct 2024 06:09:47 +0000
Subject: [PATCH] fix: toplevelevent relationship when using alias

---
 src/Plugin/views/relationship/TopLevelEvent.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/Plugin/views/relationship/TopLevelEvent.php b/src/Plugin/views/relationship/TopLevelEvent.php
index 5bbe2ea..cdf374b 100644
--- a/src/Plugin/views/relationship/TopLevelEvent.php
+++ b/src/Plugin/views/relationship/TopLevelEvent.php
@@ -26,9 +26,10 @@ class TopLevelEvent extends RelationshipPluginBase {
     $def = $this->definition;
     $def['table'] = $this->definition['base'];
     $def['field'] = $base_field;
-    $def['left_table'] = '';
+    $def['left_table'] = $this->tableAlias;
     // $this->realField;
-    $def['left_field'] = 'coalesce({' . $this->tableAlias . '}.parent_id, {' . $this->tableAlias . '}.id)';
+    // $def['left_field'] = 'coalesce({' . $this->tableAlias . '}.parent_id, {' . $this->tableAlias . '}.id)';
+    $def['left_formula'] = 'coalesce({' . $this->tableAlias . '}.parent_id, {' . $this->tableAlias . '}.id)';
 
     // Use a short alias for this:
     $alias = $def['table'] . '_' . $this->table;
-- 
GitLab