Wappler Version : v7b17
Operating System : MacOS
Server Model: NodeJS
Database Type: MySQL
Hosting Type: Docker
Expected behavior
What do you think should happen?
When joining the same table more than 1 time with an alias in the Database Query Buiilder, the existing table joins for the same table should not get replaced with the aliases.
Actual behavior
What actually happens?
When joining the same table more than 1 time with an alias in the Database Query Buiilder, the existing table joins for the same table get corrupted and are replaced with the table alias names. In addition, the new table joins are also created with the alias names.
I have included code below:
Before joining the same table more than 1 time
left join `teachers` on `teachers`.`user_id` = `users`.`id`
left join `teacher_titles` on `teacher_titles`.`teacher_id` = `teachers`.`id`
left join `teacher_title_options` on `teacher_title_options`.`id` = `teacher_titles`.`title_id`
After joining the same table with alias more than 1 time - the table names in the first 3 lines in the code have changed to aliases and new joins have also been added with aliases
left join `teachers` on `user_teachers`.`user_id` = `users`.`id`
left join `teacher_titles` on `user_teacher_titles`.`teacher_id` = `user_teachers`.`id`
left join `teacher_title_options` on `user_teacher_title_options`.`id` = `user_teacher_titles`.`title_id`
left join `teachers` as `user_teachers` on `user_teachers`.`user_id` = `user_details`.`teacher_id`
left join `teacher_titles` as `user_teacher_titles` on `user_teacher_titles`.`teacher_id` = `user_teachers`.`id`
left join `teacher_title_options` as `user_teacher_title_options` on `user_teacher_title_options`.`id` = `user_teacher_titles`.`title_id`
Correct code as a Custom Query
left join `teachers` on `teachers`.`user_id` = `users`.`id`
left join `teacher_titles` on `teacher_titles`.`teacher_id` = `teachers`.`id`
left join `teacher_title_options` on `teacher_title_options`.`id` = `teacher_titles`.`title_id`
left join `teachers` AS `user_teachers` on `user_teachers`.`id` = `user_details`.`teacher_id`
left join `teacher_titles` AS `user_teacher_titles` on `user_teacher_titles`.`teacher_id` = `user_teachers`.`id`
left join `teacher_title_options` AS `user_teacher_title_options` on `user_teacher_title_options`.`id` = `user_teacher_titles`.`title_id`