haskell - Outer Joins with Esqueleto -


i bit confused how outer joins work esqueleto.

i have created following query (simplified):

select $ $ \(rep `leftouterjoin` event) ->           on (rep ^. repatomid  ==. event   ^. eventatomid )           where_ (rep ^. repatomid  ==. val aid)           return $ (rep, event ^. eventseconds) 

as far know, on sql-side, query search reps may have associated event. if not have associated event, event fields (like eventseconds) "null". on haskell side, these should translated maybe seconds (well, ints, idea).

so happens when run query , there nothing adjoin rep relation? how deconstruct tuple stick default in?

currently, have along lines of:

case listtomaybe lrep of   ( entityval -> rep        , unvalue -> seconds        ) -> stuff 

(note have viewpatterns turned on here). type checks. fails if use (?.) , (frommaybe 3600) . unvalue in pattern analysis.

i able fix adding 'just' in right place:

select $ $ \(rep `leftouterjoin` event) ->          on (just (rep ^. repatomid)  ==. event  ?. eventatomid )          where_ (rep ^. repatomid  ==. val aid)          return $ (rep, event ?. eventseconds)  case listtomaybe lrep of   ( entityval -> rep        , (frommaybe 3600) . unvalue -> seconds        ) -> stuff 

the idea being (event) have maybe-like type (i'm not sure it's type is, know has embedded maybe). when comparing rep, comparing (maybe a) a. 'just' wrapped (maybe a), without having deconstruct intermediate type.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -