Skip to content

Associations are not checking for soft delete #4

@D4no0

Description

@D4no0

When an association is used in combination with preload, the paranoid repo is not checking whether the field deleted_at is not null.
The only workaround for this current problem is to use a query in preload:
UserRepo.get_users!(1) |> Paranoid.preload(role: Query.from(r in Role, where: is_nil(r.deleted_at)))

Taking a look at the library code the behavior of the preload is not overridden and the default one is used:

def preload(struct_or_structs_or_nil, preloads, opts \\ []) do
          unquote(repo)
          |> apply(:preload, [struct_or_structs_or_nil, preloads, opts])
        end

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