packages feed

beam-core 0.9.2.1 → 0.10.0.0

raw patch · 11 files changed

+119/−84 lines, 11 filesdep ~aesondep ~ghc-primdep ~textPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: aeson, ghc-prim, text, time

API changes (from Hackage documentation)

- Database.Beam.Backend.SQL.AST: instance Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax Database.Beam.Backend.SQL.AST.Value GHC.Integer.Type.Integer
- Database.Beam.Backend.SQL.BeamExtensions: data family SqlConflictAction be (table :: (Type -> Type) -> Type) :: Type;
- Database.Beam.Backend.SQL.Row: instance GHC.Generics.Generic (a, b, c, d, e, f, g, h)
- Database.Beam.Backend.SQL.SQL2003: type family Sql2003WindowFrameBoundsBoundSyntax bounds :: Type;
- Database.Beam.Backend.SQL.SQL92: type family Sql92FromExpressionSyntax from :: Type;
- Database.Beam.Backend.SQL.SQL99: type family Sql99CTESelectSyntax syntax :: Type;
- Database.Beam.Backend.SQL.Types: instance Data.Bits.Bits Database.Beam.Backend.SQL.Types.SqlBitString
- Database.Beam.Backend.Types: type family BackendFromField be :: Type -> Constraint;
- Database.Beam.Query.Adhoc: type family AdhocTable structure (f :: Type -> Type) :: Type;
- Database.Beam.Query.CustomSQL: data family CustomSqlSyntax syntax :: Type;
- Database.Beam.Schema: data family PrimaryKey table (column :: Type -> Type) :: Type;
- Database.Beam.Schema.Tables: data family PrimaryKey table (column :: Type -> Type) :: Type;
+ Database.Beam: runReturningFirst :: (MonadBeam be m, FromBackendRow be x) => BeamSqlBackendSyntax be -> m (Maybe x)
+ Database.Beam.Backend.SQL: runReturningFirst :: (MonadBeam be m, FromBackendRow be x) => BeamSqlBackendSyntax be -> m (Maybe x)
+ Database.Beam.Backend.SQL.AST: ExpressionInSelect :: Expression -> Select -> Expression
+ Database.Beam.Backend.SQL.AST: instance Database.Beam.Backend.SQL.SQL92.HasSqlValueSyntax Database.Beam.Backend.SQL.AST.Value GHC.Num.Integer.Integer
+ Database.Beam.Backend.SQL.BeamExtensions: data SqlConflictAction be (table :: (Type -> Type) -> Type) :: Type;
+ Database.Beam.Backend.SQL.BeamExtensions: data SqlConflictTarget be (table :: (Type -> Type) -> Type) :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003ExpressionWindowFrameSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003FromSampleMethodSyntax from :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003WindowFrameBoundsBoundSyntax bounds :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003WindowFrameBoundsSyntax frame :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003WindowFrameExpressionSyntax frame :: Type;
+ Database.Beam.Backend.SQL.SQL2003: type Sql2003WindowFrameOrderingSyntax frame :: Type;
+ Database.Beam.Backend.SQL.SQL92: inSelectE :: IsSql92ExpressionSyntax expr => expr -> Sql92ExpressionSelectSyntax expr -> expr
+ Database.Beam.Backend.SQL.SQL92: type Sql92AggregationSetQuantifierSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92DeleteExpressionSyntax delete :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92DeleteSyntax cmd :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92DeleteTableNameSyntax delete :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionCastTargetSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionExtractFieldSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionFieldNameSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionQuantifierSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionSelectSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ExpressionValueSyntax expr :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92FromExpressionSyntax from :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92FromTableSourceSyntax from :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92GroupingExpressionSyntax grouping :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92InsertSyntax cmd :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92InsertTableNameSyntax insert :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92InsertValuesExpressionSyntax insertValues :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92InsertValuesSelectSyntax insertValues :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92InsertValuesSyntax insert :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92OrderingExpressionSyntax ord :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92ProjectionExpressionSyntax proj :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectOrderingSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectSelectTableSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectSyntax cmd :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableExpressionSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableFromSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableGroupingSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableProjectionSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableSelectSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92SelectTableSetQuantifierSyntax select :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92TableSourceExpressionSyntax tblSource :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92TableSourceSelectSyntax tblSource :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92TableSourceTableNameSyntax tblSource :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92UpdateExpressionSyntax update :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92UpdateFieldNameSyntax update :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92UpdateSyntax cmd :: Type;
+ Database.Beam.Backend.SQL.SQL92: type Sql92UpdateTableNameSyntax update :: Type;
+ Database.Beam.Backend.SQL.SQL99: type Sql99CTESelectSyntax syntax :: Type;
+ Database.Beam.Backend.SQL.SQL99: type Sql99SelectCTESyntax syntax :: Type;
+ Database.Beam.Backend.SQL.Types: instance GHC.Bits.Bits Database.Beam.Backend.SQL.Types.SqlBitString
+ Database.Beam.Backend.Types: type BackendFromField be :: Type -> Constraint;
+ Database.Beam.Query: inQuery_ :: (HasQBuilder be, BeamSqlBackend be) => QGenExpr ctx be s a -> Q be db s (QExpr be s a) -> QGenExpr ctx be s Bool
+ Database.Beam.Query: runSelectReturningFirst :: (MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) => SqlSelect be a -> m (Maybe a)
+ Database.Beam.Query.Adhoc: type AdhocTable structure (f :: Type -> Type) :: Type;
+ Database.Beam.Query.CustomSQL: data CustomSqlSyntax syntax :: Type;
+ Database.Beam.Query.Internal: type WithRewrittenContext a ctxt :: Type;
+ Database.Beam.Query.Internal: type WithRewrittenThread s (s' :: Type) a :: Type;
+ Database.Beam.Schema: data PrimaryKey table (column :: Type -> Type) :: Type;
+ Database.Beam.Schema.Tables: data DatabaseEntityDescriptor be entityType :: Type;
+ Database.Beam.Schema.Tables: data PrimaryKey table (column :: Type -> Type) :: Type;
+ Database.Beam.Schema.Tables: type DatabaseEntityDefaultRequirements be entityType :: Constraint;
+ Database.Beam.Schema.Tables: type DatabaseEntityRegularRequirements be entityType :: Constraint;
+ Database.Beam.Schema.Tables: type Retag (tag :: (Type -> Type) -> Type -> Type) x :: Type;
- Database.Beam.Backend.URI: [OpenedBeamConnection] :: {beamRunner :: forall a. hdl -> m a -> IO a, openedBeamDatabase :: c be hdl m, openedBeamHandle :: hdl, closeBeamConnection :: IO ()} -> OpenedBeamConnection c
+ Database.Beam.Backend.URI: [OpenedBeamConnection] :: (forall a. hdl -> m a -> IO a) -> c be hdl m -> hdl -> IO () -> OpenedBeamConnection c
- Database.Beam.Query.Internal: [QArbitraryJoin] :: Projectible be r => QM be db (QNested s) r -> (BeamSqlBackendFromSyntax be -> BeamSqlBackendFromSyntax be -> Maybe (BeamSqlBackendExpressionSyntax be) -> BeamSqlBackendFromSyntax be) -> (r -> Maybe (WithExprContext (BeamSqlBackendExpressionSyntax be))) -> (r -> next) -> QF be db s next
+ Database.Beam.Query.Internal: [QArbitraryJoin] :: Projectible be r => QM be db (QNested s) r -> Text -> (BeamSqlBackendFromSyntax be -> BeamSqlBackendFromSyntax be -> Maybe (BeamSqlBackendExpressionSyntax be) -> BeamSqlBackendFromSyntax be) -> (r -> Maybe (WithExprContext (BeamSqlBackendExpressionSyntax be))) -> (r -> next) -> QF be db s next
- Database.Beam.Query.Internal: type family WithRewrittenContext a ctxt :: Type;
+ Database.Beam.Query.Internal: type family ValueContextSuggestion a :: ErrorMessage
- Database.Beam.Schema.Tables: type family Retag (tag :: (Type -> Type) -> Type -> Type) x :: Type;
+ Database.Beam.Schema.Tables: type family ReplaceBaseTag tag f

Files

Database/Beam/Backend/SQL.hs view
@@ -133,6 +133,12 @@                  Nothing -> pure (Just x)                  Just _ -> pure Nothing +  -- | Run the given command and fetch the first result. The result is+  --   'Nothing' if no results are returned.+  --   This is not guaranteed to automatically limit the query to one result.+  runReturningFirst :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x)+  runReturningFirst cmd = runReturningMany cmd id+   -- | Run the given command, collect all the results, and return them as a   --   list. May be more convenient than 'runReturningMany', but reads the entire   --   result set into memory.
Database/Beam/Backend/SQL/AST.hs view
@@ -234,6 +234,7 @@   | ExpressionRow [ Expression ]    | ExpressionIn Expression [ Expression ]+  | ExpressionInSelect Expression Select    | ExpressionIsNull Expression   | ExpressionIsNotNull Expression@@ -359,6 +360,7 @@    defaultE = ExpressionDefault   inE = ExpressionIn+  inSelectE = ExpressionInSelect  instance IsSql99FunctionExpressionSyntax Expression where   functionNameE = ExpressionNamedFunction
Database/Beam/Backend/SQL/Builder.hs view
@@ -272,7 +272,9 @@    defaultE = SqlSyntaxBuilder (byteString "DEFAULT")   inE a es = SqlSyntaxBuilder (byteString "(" <> buildSql a <> byteString ") IN (" <>-                               buildSepBy (byteString ", ") (map buildSql es))+                               buildSepBy (byteString ", ") (map buildSql es) <> byteString ")")+  inSelectE a sel = SqlSyntaxBuilder (byteString "(" <> buildSql a <> byteString ") IN (" <>+                                      buildSql sel <> byteString ")")  instance IsSql99FunctionExpressionSyntax SqlSyntaxBuilder where   functionNameE fn = SqlSyntaxBuilder (byteString (TE.encodeUtf8 fn))
Database/Beam/Backend/SQL/SQL92.hs view
@@ -315,6 +315,7 @@   defaultE :: expr    inE :: expr -> [ expr ] -> expr+  inSelectE :: expr -> Sql92ExpressionSelectSyntax expr -> expr  instance HasSqlValueSyntax syntax x => HasSqlValueSyntax syntax (SqlSerial x) where   sqlValueSyntax (SqlSerial x) = sqlValueSyntax x
Database/Beam/Query.hs view
@@ -45,6 +45,7 @@     , HasTableEquality     , SqlEq(..), SqlOrd(..), SqlIn(..)     , HasSqlInTable(..)+    , inQuery_      -- ** Quantified Comparison Operators #quantified-comparison-operator#     , SqlEqQuantified(..), SqlOrdQuantified(..)@@ -64,6 +65,7 @@     , select, selectWith, lookup_     , runSelectReturningList     , runSelectReturningOne+    , runSelectReturningFirst     , dumpSqlSelect      -- ** @INSERT@@@ -194,6 +196,15 @@   SqlSelect be a -> m (Maybe a) runSelectReturningOne (SqlSelect s) =   runReturningOne (selectCmd s)++-- | Run a 'SqlSelect' in a 'MonadBeam' and get the first result, if there is+--   one.+--   This is not guaranteed to automatically limit the query to one result.+runSelectReturningFirst ::+  (MonadBeam be m, BeamSqlBackend be, FromBackendRow be a) =>+  SqlSelect be a -> m (Maybe a)+runSelectReturningFirst (SqlSelect s) =+  runReturningFirst (selectCmd s)  -- | Use a special debug syntax to print out an ANSI Standard @SELECT@ statement --   that may be generated for a given 'Q'.
Database/Beam/Query/Combinators.hs view
@@ -152,7 +152,7 @@          -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) perhaps_ (Q sub) =   Q $ liftF (QArbitraryJoin-              sub leftJoin+              sub "" leftJoin               (\_ -> Nothing)               (\r -> retag (\(Columnar' (QExpr e) :: Columnar' (QExpr be s) a) ->                                             Columnar' (QExpr e) :: Columnar' (Nullable (QExpr be s)) a) $@@ -232,7 +232,7 @@            -> Q be db s (Retag Nullable (WithRewrittenThread (QNested s) s r)) leftJoin_' (Q sub) on_ =   Q $ liftF (QArbitraryJoin-               sub leftJoin+               sub "" leftJoin                (\r -> let QExpr e = on_ (rewriteThread (Proxy @s) r) in Just e)                (\r -> retag (\(Columnar' (QExpr e) :: Columnar' (QExpr be s) a) ->                                 Columnar' (QExpr e) :: Columnar' (Nullable (QExpr be s)) a) $@@ -854,7 +854,7 @@     isNothing_ t = allE (allBeamValues (\(Columnar' e) -> isNothing_ e) t)     maybe_ (QExpr onNothing) onJust tbl =       let QExpr onJust' = onJust (changeBeamRep (\(Columnar' (QExpr e)) -> Columnar' (QExpr e)) tbl)-          QExpr cond = isJust_ tbl+          QExpr cond = isJust_ @be tbl       in QExpr (\tblPfx -> caseE [(cond tblPfx, onJust' tblPfx)] (onNothing tblPfx))  infixl 3 <|>.
Database/Beam/Query/Internal.hs view
@@ -47,6 +47,7 @@    QArbitraryJoin :: Projectible be r                  => QM be db (QNested s) r+                 -> T.Text -- Table namespace                  -> (BeamSqlBackendFromSyntax be -> BeamSqlBackendFromSyntax be ->                      Maybe (BeamSqlBackendExpressionSyntax be) ->                      BeamSqlBackendFromSyntax be)
Database/Beam/Query/Ord.hs view
@@ -38,6 +38,8 @@   , anyOf_, anyIn_   , allOf_, allIn_ +  , inQuery_+   , between_   ) where @@ -199,7 +201,11 @@     where toExpr :: table (QGenExpr context be s) -> TablePrefix -> BeamSqlBackendExpressionSyntax be           toExpr = fmap rowE . sequence . allBeamValues (\(Columnar' (QExpr x)) -> x) -infix 4 `between_`, `in_`+infix 4 `between_`, `in_`, `inQuery_`++inQuery_ :: (HasQBuilder be, BeamSqlBackend be)+         => QGenExpr ctx be s a -> Q be db s (QExpr be s a) -> QGenExpr ctx be s Bool+inQuery_ (QExpr needle) haystack = QExpr (inSelectE <$> needle <*> flip buildSqlQuery haystack)  -- | Class for expression types or expression containers for which there is a --   notion of equality.
Database/Beam/Query/SQL92.hs view
@@ -212,28 +212,29 @@                  -> T.Text {-^ Table prefix -}                  -> Q be db s a                  -> BeamSqlBackendSelectSyntax be-buildSql92Query' arbitrarilyNestedCombinations tblPfx (Q q) =-    buildSelect tblPfx (buildQuery (fromF q))+buildSql92Query' arbitrarilyNestedCombinations baseTblPfx (Q q) =+    buildSelect baseTblPfx (buildQuery baseTblPfx (fromF q))   where     be :: Proxy be     be = Proxy      buildQuery :: forall s x                 . Projectible be x-               => Free (QF be db s) x+               => T.Text+               -> Free (QF be db s) x                -> SelectBuilder be db x-    buildQuery (Pure x) = SelectBuilderQ x emptyQb-    buildQuery (Free (QGuard _ next)) = buildQuery next-    buildQuery f@(Free QAll {}) = buildJoinedQuery f emptyQb-    buildQuery f@(Free QArbitraryJoin {}) = buildJoinedQuery f emptyQb-    buildQuery f@(Free QTwoWayJoin {}) = buildJoinedQuery f emptyQb-    buildQuery (Free (QSubSelect q' next)) =-        let sb = buildQuery (fromF q')+    buildQuery _ (Pure x) = SelectBuilderQ x emptyQb+    buildQuery tblPfx (Free (QGuard _ next)) = buildQuery tblPfx next+    buildQuery tblPfx f@(Free QAll {}) = buildJoinedQuery tblPfx f emptyQb+    buildQuery tblPfx f@(Free QArbitraryJoin {}) = buildJoinedQuery tblPfx f emptyQb+    buildQuery tblPfx f@(Free QTwoWayJoin {}) = buildJoinedQuery tblPfx f emptyQb+    buildQuery tblPfx (Free (QSubSelect q' next)) =+        let sb = buildQuery tblPfx (fromF q')             (proj, qb) = selectBuilderToQueryBuilder tblPfx sb-        in buildJoinedQuery (next proj) qb-    buildQuery (Free (QDistinct nubType q' next)) =+        in buildJoinedQuery tblPfx (next proj) qb+    buildQuery tblPfx (Free (QDistinct nubType q' next)) =       let (proj, qb, gp, hv) =-            case buildQuery (fromF q') of+            case buildQuery tblPfx (fromF q') of               SelectBuilderQ proj qb ->                 ( proj, qb, Nothing, Nothing)               SelectBuilderGrouping proj qb gp hv Nothing ->@@ -244,11 +245,11 @@       in case next proj of            Pure x -> SelectBuilderGrouping x qb gp hv (Just (exprWithContext tblPfx (nubType proj)))            _ -> let ( proj', qb' ) = selectBuilderToQueryBuilder tblPfx (SelectBuilderGrouping proj qb gp hv (Just (exprWithContext tblPfx (nubType proj))))-                in buildJoinedQuery (next proj') qb'-    buildQuery (Free (QAggregate mkAgg q' next)) =-        let sb = buildQuery (fromF q')+                in buildJoinedQuery tblPfx (next proj') qb'+    buildQuery tblPfx (Free (QAggregate mkAgg q' next)) =+        let sb = buildQuery tblPfx (fromF q')             (groupingSyntax, aggProj) = mkAgg (sbProj sb) (nextTblPfx tblPfx)-        in case tryBuildGuardsOnly (next aggProj) Nothing of+        in case tryBuildGuardsOnly tblPfx (next aggProj) Nothing of             Just (proj, having) ->                 case sb of                   SelectBuilderQ _ q'' -> SelectBuilderGrouping proj q'' groupingSyntax having Nothing@@ -256,13 +257,13 @@                   -- We'll have to generate a subselect                   _ -> let (subProj, qb) = selectBuilderToQueryBuilder tblPfx sb --(setSelectBuilderProjection sb aggProj)                            (groupingSyntax, aggProj') = mkAgg subProj (nextTblPfx tblPfx)-                       in case tryBuildGuardsOnly (next aggProj') Nothing of+                       in case tryBuildGuardsOnly tblPfx (next aggProj') Nothing of                             Nothing -> error "buildQuery (Free (QAggregate ...)): Impossible"                             Just (aggProj'', having') ->                               SelectBuilderGrouping aggProj'' qb groupingSyntax having' Nothing             Nothing ->-              let (_, having) = tryCollectHaving (next aggProj') Nothing-                  (next', _) = tryCollectHaving (next x') Nothing+              let (_, having) = tryCollectHaving tblPfx (next aggProj') Nothing+                  (next', _) = tryCollectHaving tblPfx (next x') Nothing                   (groupingSyntax', aggProj', qb) =                     case sb of                       SelectBuilderQ _ q'' -> (groupingSyntax, aggProj, q'')@@ -271,10 +272,10 @@                            in (groupingSyntax', aggProj', qb''')                   (x', qb') = selectBuilderToQueryBuilder tblPfx $                               SelectBuilderGrouping aggProj' qb groupingSyntax' having Nothing-              in buildJoinedQuery next' qb'+              in buildJoinedQuery tblPfx next' qb' -    buildQuery (Free (QOrderBy mkOrdering q' next)) =-        let sb = buildQuery (fromF q')+    buildQuery tblPfx (Free (QOrderBy mkOrdering q' next)) =+        let sb = buildQuery tblPfx (fromF q')             proj = sbProj sb             ordering = exprWithContext tblPfx (mkOrdering proj) @@ -296,7 +297,7 @@                                 | otherwise -> error "buildQuery (Free (QOrderBy ...)): query inspected expression"                      (joinedProj, qb) = selectBuilderToQueryBuilder tblPfx sb'-                in buildJoinedQuery (next joinedProj) qb+                in buildJoinedQuery tblPfx (next joinedProj) qb         in case next proj of              Pure proj' ->                case ordering of@@ -320,8 +321,8 @@                            | otherwise -> error "buildQuery (Free (QOrderBy ...)): query inspected expression"              _ -> doJoined -    buildQuery (Free (QWindowOver mkWindows mkProjection q' next)) =-        let sb = buildQuery (fromF q')+    buildQuery tblPfx (Free (QWindowOver mkWindows mkProjection q' next)) =+        let sb = buildQuery tblPfx (fromF q')              x = sbProj sb             windows = mkWindows x@@ -334,10 +335,10 @@                  sb' -> SelectBuilderTopLevel Nothing Nothing [] sb' Nothing              _       ->                let (x', qb) = selectBuilderToQueryBuilder tblPfx (setSelectBuilderProjection sb projection)-               in buildJoinedQuery (next x') qb+               in buildJoinedQuery tblPfx (next x') qb -    buildQuery (Free (QLimit limit q' next)) =-        let sb = limitSelectBuilder limit (buildQuery (fromF q'))+    buildQuery tblPfx (Free (QLimit limit q' next)) =+        let sb = limitSelectBuilder limit (buildQuery tblPfx (fromF q'))             x = sbProj sb         -- In the case of limit, we must directly return whatever was given         in case next x of@@ -345,23 +346,23 @@               -- Otherwise, this is going to be part of a join...              _ -> let (x', qb) = selectBuilderToQueryBuilder tblPfx sb-                  in buildJoinedQuery (next x') qb+                  in buildJoinedQuery tblPfx (next x') qb -    buildQuery (Free (QOffset offset q' next)) =-        let sb = offsetSelectBuilder offset (buildQuery (fromF q'))+    buildQuery tblPfx (Free (QOffset offset q' next)) =+        let sb = offsetSelectBuilder offset (buildQuery tblPfx (fromF q'))             x = sbProj sb         -- In the case of limit, we must directly return whatever was given         in case next x of              Pure x' -> setSelectBuilderProjection sb x'              -- Otherwise, this is going to be part of a join...              _ -> let (x', qb) = selectBuilderToQueryBuilder tblPfx sb-                  in buildJoinedQuery (next x') qb+                  in buildJoinedQuery tblPfx (next x') qb -    buildQuery (Free (QSetOp combine left right next)) =-      buildTableCombination combine left right next+    buildQuery tblPfx (Free (QSetOp combine left right next)) =+      buildTableCombination tblPfx combine left right next -    buildQuery (Free (QForceSelect selectStmt' over next)) =-      let sb = buildQuery (fromF over)+    buildQuery tblPfx (Free (QForceSelect selectStmt' over next)) =+      let sb = buildQuery tblPfx (fromF over)           x = sbProj sb            selectStmt'' = selectStmt' (sbProj sb)@@ -375,33 +376,36 @@       in case next (sbProj sb') of            Pure x' -> setSelectBuilderProjection sb' x'            _ -> let (x', qb) = selectBuilderToQueryBuilder tblPfx sb'-                in buildJoinedQuery (next x') qb+                in buildJoinedQuery tblPfx (next x') qb      tryBuildGuardsOnly :: forall s x-                        . Free (QF be db s) x+                        . T.Text+                       -> Free (QF be db s) x                        -> Maybe (BeamSqlBackendExpressionSyntax be)                        -> Maybe (x, Maybe (BeamSqlBackendExpressionSyntax be))-    tryBuildGuardsOnly next having =-      case tryCollectHaving next having of+    tryBuildGuardsOnly tblPfx next having =+      case tryCollectHaving tblPfx next having of         (Pure x, having') -> Just (x, having')         _ -> Nothing -    tryCollectHaving :: forall s x.-                        Free (QF be db s) x+    tryCollectHaving :: forall s x+                      . T.Text+                     -> Free (QF be db s) x                      -> Maybe (BeamSqlBackendExpressionSyntax be)                      -> (Free (QF be db s) x, Maybe (BeamSqlBackendExpressionSyntax be))-    tryCollectHaving (Free (QGuard cond next)) having = tryCollectHaving next (andE' having (Just (exprWithContext tblPfx cond)))-    tryCollectHaving next having = (next, having)+    tryCollectHaving tblPfx (Free (QGuard cond next)) having = tryCollectHaving tblPfx next (andE' having (Just (exprWithContext tblPfx cond)))+    tryCollectHaving _ next having = (next, having)      buildTableCombination       :: forall s x r        . ( Projectible be r, Projectible be x )-      => (BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be)+      => T.Text+      -> (BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be -> BeamSqlBackendSelectTableSyntax be)       -> QM be db (QNested s) x -> QM be db (QNested s) x -> (x -> Free (QF be db s) r) -> SelectBuilder be db r-    buildTableCombination combineTables left right next =-        let leftSb = buildQuery (fromF left)+    buildTableCombination tblPfx combineTables left right next =+        let leftSb = buildQuery tblPfx (fromF left)             leftTb = selectBuilderToTableSource tblPfx leftSb-            rightSb = buildQuery (fromF right)+            rightSb = buildQuery tblPfx (fromF right)             rightTb = selectBuilderToTableSource tblPfx rightSb              proj = reproject be (fieldNameFunc unqualifiedField) (sbProj leftSb)@@ -423,16 +427,16 @@                | projOrder be proj (nextTblPfx tblPfx) == projOrder be proj' (nextTblPfx tblPfx) ->                    setSelectBuilderProjection sb proj'              _ -> let (x', qb) = selectBuilderToQueryBuilder tblPfx sb-                  in buildJoinedQuery (next x') qb+                  in buildJoinedQuery tblPfx (next x') qb -    buildJoinedQuery :: forall s x.-                        Projectible be x =>-                        Free (QF be db s) x -> QueryBuilder be -> SelectBuilder be db x-    buildJoinedQuery (Pure x) qb = SelectBuilderQ x qb-    buildJoinedQuery (Free (QAll mkFrom mkTbl on next)) qb =+    buildJoinedQuery :: forall s x+                      . Projectible be x+                     => T.Text -> Free (QF be db s) x -> QueryBuilder be -> SelectBuilder be db x+    buildJoinedQuery _ (Pure x) qb = SelectBuilderQ x qb+    buildJoinedQuery tblPfx (Free (QAll mkFrom mkTbl on next)) qb =         let (newTblNm, newTbl, qb') = buildInnerJoinQuery tblPfx mkFrom mkTbl on qb-        in buildJoinedQuery (next (newTblNm, newTbl)) qb'-    buildJoinedQuery (Free (QArbitraryJoin q mkJoin on next)) qb =+        in buildJoinedQuery tblPfx (next (newTblNm, newTbl)) qb'+    buildJoinedQuery tblPfx (Free (QArbitraryJoin q tblNs mkJoin on next)) qb =       case fromF q of         Free (QAll mkDbFrom dbMkTbl on' next')           | (newTbl, newTblNm, qb') <- nextTbl qb tblPfx dbMkTbl,@@ -444,10 +448,12 @@                   case qbFrom qb' of                     Nothing -> (Just newSource, andE' (qbWhere qb) on'')                     Just oldFrom -> (Just (mkJoin oldFrom newSource on''), qbWhere qb)-            in buildJoinedQuery (next proj) (qb' { qbFrom = from', qbWhere = where' })+            in buildJoinedQuery tblPfx (next proj) (qb' { qbFrom = from', qbWhere = where' }) -        q' -> let sb = buildQuery q'-                  tblSource = buildSelect tblPfx sb+        q' -> let tblPfx' = tblPfx <> tblNs++                  sb = buildQuery tblPfx' q'+                  tblSource = buildSelect tblPfx' sb                   newTblNm = tblPfx <> fromString (show (qbNextTblRef qb))                    newSource = fromTable (tableFromSubSelect tblSource) (Just (newTblNm, Nothing))@@ -460,9 +466,9 @@                       Nothing -> (Just newSource, andE' (qbWhere qb) on')                       Just oldFrom -> (Just (mkJoin oldFrom newSource on'), qbWhere qb) -              in buildJoinedQuery (next proj') (qb { qbNextTblRef = qbNextTblRef qb + 1-                                                   , qbFrom = from', qbWhere = where' })-    buildJoinedQuery (Free (QTwoWayJoin a b mkJoin on next)) qb =+              in buildJoinedQuery tblPfx (next proj') (qb { qbNextTblRef = qbNextTblRef qb + 1+                                                          , qbFrom = from', qbWhere = where' })+    buildJoinedQuery tblPfx (Free (QTwoWayJoin a b mkJoin on next)) qb =       let (aProj, aSource, qb') =             case fromF a of               Free (QAll mkDbFrom dbMkTbl on' next')@@ -470,7 +476,7 @@                   Nothing <- on' newTbl, Pure proj <- next' (newTblNm, newTbl) ->                     (proj, mkDbFrom (nextTblPfx tblPfx) newTblNm, qb') -              a -> let sb = buildQuery a+              a -> let sb = buildQuery tblPfx a                        tblSource = buildSelect tblPfx sb                         newTblNm = tblPfx <> fromString (show (qbNextTblRef qb))@@ -485,7 +491,7 @@                   Nothing <- on' newTbl, Pure proj <- next' (newTblNm, newTbl) ->                     (proj, mkDbFrom (nextTblPfx tblPfx) newTblNm, qb'') -              b -> let sb = buildQuery b+              b -> let sb = buildQuery tblPfx b                        tblSource = buildSelect tblPfx sb                         newTblNm = tblPfx <> fromString (show (qbNextTblRef qb))@@ -500,16 +506,16 @@               Nothing -> Just abSource               Just oldFrom -> Just (innerJoin oldFrom abSource Nothing) -      in buildJoinedQuery (next (aProj, bProj)) (qb'' { qbFrom = from' })-    buildJoinedQuery (Free (QGuard cond next)) qb =-        buildJoinedQuery next (qb { qbWhere = andE' (qbWhere qb) (Just (exprWithContext tblPfx cond)) })-    buildJoinedQuery now qb =+      in buildJoinedQuery tblPfx (next (aProj, bProj)) (qb'' { qbFrom = from' })+    buildJoinedQuery tblPfx (Free (QGuard cond next)) qb =+        buildJoinedQuery tblPfx next (qb { qbWhere = andE' (qbWhere qb) (Just (exprWithContext tblPfx cond)) })+    buildJoinedQuery tblPfx now qb =       onlyQ now         (\now' next ->-           let sb = buildQuery now'+           let sb = buildQuery tblPfx now'                tblSource = buildSelect tblPfx sb                (x', qb') = buildJoinTableSourceQuery tblPfx tblSource (sbProj sb) qb-           in buildJoinedQuery (next x') qb')+           in buildJoinedQuery tblPfx (next x') qb')      onlyQ :: forall s x.              Free (QF be db s) x@@ -518,8 +524,8 @@     onlyQ (Free (QAll entityNm mkTbl mkOn next)) f =       f (Free (QAll entityNm mkTbl mkOn (Pure . PreserveLeft))) (next . unPreserveLeft) --      f (Free (QAll entityNm mkTbl mkOn (Pure . PreserveLeft))) (next . unPreserveLeft)-    onlyQ (Free (QArbitraryJoin entity mkJoin mkOn next)) f =-      f (Free (QArbitraryJoin entity mkJoin mkOn Pure)) next+    onlyQ (Free (QArbitraryJoin entity tblNs mkJoin mkOn next)) f =+      f (Free (QArbitraryJoin entity tblNs mkJoin mkOn Pure)) next     onlyQ (Free (QTwoWayJoin a b mkJoin mkOn next)) f =       f (Free (QTwoWayJoin a b mkJoin mkOn Pure)) next     onlyQ (Free (QSubSelect q' next)) f =
Database/Beam/Schema/Tables.hs view
@@ -447,7 +447,7 @@ -- >                   { _refToAnotherTable :: PrimaryKey AnotherTableT (Nullable f) -- >                   , ... } -----   Now we can use 'justRef' and 'nothingRef' to refer to this table optionally. The embedded 'PrimaryKey' in '_refToAnotherTable'+--   Now we can use 'just_' and 'nothing_' to refer to this table optionally. The embedded 'PrimaryKey' in '_refToAnotherTable' --   automatically has its fields converted into 'Maybe' using 'Nullable'. -- --   The last 'Columnar' rule is
beam-core.cabal view
@@ -2,7 +2,7 @@ -- see http://haskell.org/cabal/users-guide/  name:                beam-core-version:             0.9.2.1+version:             0.10.0.0 synopsis:            Type-safe, feature-complete SQL query and manipulation interface for Haskell description:         Beam is a Haskell library for type-safe querying and manipulation of SQL databases.                      Beam is modular and supports various backends. In order to use beam, you will need to use@@ -61,15 +61,15 @@                        Database.Beam.Schema.Lenses    build-depends:       base         >=4.11    && <5.0,-                       aeson        >=0.11    && <2.1,-                       text         >=1.2.2.0 && <1.3,+                       aeson        >=0.11    && <2.2,+                       text         >=1.2.2.0 && <2.1,                        bytestring   >=0.10    && <0.12,                        mtl          >=2.2.1   && <2.3,                        microlens    >=0.4     && <0.5,-                       ghc-prim     >=0.5     && <0.9,+                       ghc-prim     >=0.5     && <0.10,                        free         >=4.12    && <5.2,                        dlist        >=0.7.1.2 && <1.1,-                       time         >=1.6     && <1.12,+                       time         >=1.6     && <1.13,                        hashable     >=1.2.4.0 && <1.5,                        network-uri  >=2.6     && <2.7,                        containers   >=0.5     && <0.7,