Open 9999years opened 1 year ago
I have a version that compiles and I believe generates the desired instance here:
I wasn't sure if the scope was larger than this (are there other instances that are needed?)
I assume what else is left is:
-- * @x@ is transformed into @'SqlExpr' ('Value' ('Maybe' x))@.
-- * If there exists an instance @'SqlSelect' sql x@, then @x@ is transformed into @sql@.
Proper acceptance critieria is going to include a test where we can define a subquery that returns a SqlMyRecord
and you can left join on it, and the result is a SqlMaybeMyRecord
, and parsing/query execution works out fine
@parsonsmatt would this suffice for acceptance:
mySubselectRecordQuery :: SqlQuery (SqlExpr (Maybe (Entity Address)))
mySubselectRecordQuery = do
_ :& record <-
from $ table @User
`leftJoin` myRecordQuery
`on` (do \(user :& record) -> just (user ^. #id) ==. record.myUser ?. #id)
pure $ record.myAddress
itDb "can left join on records" $ do
setup
[record] <- fmap entityVal . catMaybes <$> select mySubselectRecordQuery
liftIO $ record
`shouldSatisfy`
(\case Address { addressAddress = "30-50 Feral Hogs Rd" } -> True
_ -> False)
Before submitting your PR, check that you've:
@since
declarations to the Haddock.stylish-haskell
and otherwise adhered to the style guide.After submitting your PR: