Skip to content

Default behaviour of assocSelect in conjunction with has? #28

@saurabhnanda

Description

@saurabhnanda

Just playing around with pg-orm for the first time. Created the typical user-post-comments data model, and was surprised with the following:

userPosts :: Association User Post
userPosts = has

postUser :: Association Post User
postUser = belongsTo

main = do
  -- snip
  putStrLn "Finding user with posts..."
  r <- dbSelect conn $ assocSelect userPosts
  putStrLn $ show r

  -- OUTPUT: []

It seems that assocSelect uses an inner-join, which means that if a user doesn't have any posts, the entire row is not returned. Is this intended?

What's the easiest way to select a user, along with posts, but still return the user's row irrespective of whether he/she has posts, or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions