Need support for duplicate table alias
kdhrubo opened this issue · 2 comments
I encountered this problem when using the Sakila database where a film has 2 foreign keys pointing to language table. So if have to get films and their language and alternative language I need to inner join first and then outer join but with the same language table. However mybatis dynamic SQL does not allow duplicate table due to the map it stores and then validates if table with given alias already exists. the check is on table.
This seems to be a common scenario with CRMs. - lead, opportunity , account , contact etc have multiple columns which link via foreign key to list of values table.
So relaxation of this check will help build the joins.
Example failing query
select
*
from
film f
join language l1
on l1.language_id = f.language_id
right join language l2
on l2.language_id = f.original_language_id
We have solutions for this problem built in to the library. See this page for details: https://mybatis.org/mybatis-dynamic-sql/docs/databaseObjects.html#aliased-tables
Thanks was able to solve the issue following these instructions.
Closing issue. .