Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.
This repository was archived by the owner on May 25, 2022. It is now read-only.

how to do left joins properly? #25

Description

@martyall

I feel like it should be possible to do something like the following:

type DBUserCols = '[CUserId, CUsername]

userTable :: Table (Record DBUserCols) (Record DBUserCols)
userTable = Table "user" defaultRecTable

type DBAddressCols = '[CUserId, CCity, CStreet]
type DBMaybeAddressCols = '[Nullable CUserId, Nullable CCity, Nullable CStreet]

addressTable :: Table (Record DBUserCols) (Record DBUserCols)
addressTable = Table "user" defaultRecTable
 
usersWithAddressQ :: Query (Record DBUserCols, DBMaybeUserAddress)
usersWithAddressQ =
  let joiner l r = (l , allToNullable r)
       joinerL = (l, null)
       matcher l r  = l ^. cUserId .== r ^. cUserId
  in leftJoinF joiner joinerL matcher (queryTable userTable) (queryTable addressTable)

Is this already possible and I just haven't done it correctly? I don't see anything like the allToNullable above.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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