Skip to content

Wrong table alias assignment for bulk update and bulk delete #89

@alex-kulakov

Description

@alex-kulakov

Bulk Update and Bulk Delete Incorrectly assign aliases for SQL query parts when join of Update/Delete operation and base SqlSelect query is performed using IN. For instance, PostgreSQL provider uses such join.

Test query

var query = session.Query.All<DowntimeReason>()
          .Where(r => r.DowntimeInfo.Record.Equipment.Id == 333);

is translated to :

DELETE FROM "public"."DowntimeReason" WHERE ("DowntimeReason"."Id" IN (SELECT "a"."Id" FROM "public"."DowntimeReason" "b" LEFT OUTER JOIN "public"."DowntimeInfo" "c" ON ("b"."DowntimeInfo.Id" = "c"."Id") LEFT OUTER JOIN "public"."Record" "d" ON ("c"."Record.Id" = "d"."Id") WHERE ("d"."Equipment.Id" = @p0_0)))

which leads to exception, because of absence of table with "a" alias

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions