Skip to content

Alias for table in deleteFrom #488

Closed
@apozo-copyright

Description

@apozo-copyright

Please, add support for alias in deleteFrom, otherwise there is no way of using it with exists condition when there are ambiguous columns.

deleteFrom(ENTITY_A).
    where(notExists(
        select(ENTITY_B.id).from(ENTITY_B).where(ENTITY_B.a_id, isEqualTo(ENTITY_A.id))))
    .build().render(RenderingStrategies.MYBATIS3);

If columns A.id & B.a_id have the same name (let's say 'aId'), the resulting sql doesn't work as confuse the column from A with the one in B. This is translated to:
delete from A where not exists (select id from b where aId = aId);
It doesn't matter if an alias is used for B, it's still considering the right part of the equal a column from B:
delete from A where not exists (select id from b as alias where alias.aId = aId);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions