Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Joined model doesn't use deletedAt property to exclude results #623

Closed
jonny7 opened this issue Apr 1, 2019 · 1 comment
Closed

Joined model doesn't use deletedAt property to exclude results #623

jonny7 opened this issue Apr 1, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@jonny7
Copy link
Member

jonny7 commented Apr 1, 2019

Hi Tanner

Wrote this query last night:

UserOrganization.query(on: connection)
                .join(\Organization.id, to: \UserOrganization.organizationId)
                .filter(\UserOrganization.userId == id)
                .sort(\Organization.createdAt, .descending)
                .range(range)
                .alsoDecode(Organization.self)
                .all()

It returns:

SELECT * 
FROM "user_organization" 
    INNER JOIN "Organization" 
        ON "user_organization"."organizationId" = "Organization"."id" 
WHERE ("user_organization"."deletedAt" IS NULL OR "user_organization"."deletedAt" > ($1)) AND "user_organization"."userId" = ($2) 
ORDER BY "Organization"."createdAt" DESC 
LIMIT 1 OFFSET 5

Organization had to manually be added in .filter(\Organization.deletedAt == nil) to not return deleted organizations :)

@tanner0101 tanner0101 added the bug Something isn't working label Apr 10, 2019
@tanner0101 tanner0101 added this to To Do in Vapor 3 via automation Apr 10, 2019
@tanner0101 tanner0101 added this to To Do in Vapor 4 via automation Apr 10, 2019
@tanner0101
Copy link
Member

This should be fixed now, thanks!

Vapor 3 automation moved this from To Do to Done Mar 6, 2020
Vapor 4 automation moved this from Backlog to Done Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Vapor 4
  
Done
Vapor 3
  
Done
Development

No branches or pull requests

2 participants