on dev help sign in
work thru some more
commit7076866917642699da8034cdae0b25a354e0cda9 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 23 Nov 2018, 19:39 (8 years ago) parentec70c9f
4 files changed+116−116
squeal-postgresql/squeal-postgresql.cabal+1−1 squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+86−86 squeal-postgresql/src/Squeal/PostgreSQL/Pool.hs+18−18 squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+11−11
squeal-postgresql/squeal-postgresql.cabal+1−1
@@ -26,7 +26,7 @@ library
2626 Squeal.PostgreSQL.Definition
2727 Squeal.PostgreSQL.Expression
2828 Squeal.PostgreSQL.Manipulation
29− Squeal.PostgreSQL.Migration
29+ -- Squeal.PostgreSQL.Migration
3030 Squeal.PostgreSQL.Pool
3131 Squeal.PostgreSQL.PQ
3232 Squeal.PostgreSQL.Render
squeal-postgresql/src/Squeal/PostgreSQL/PQ.hs+86−86
@@ -11,7 +11,7 @@ a `Definition` and `MonadPQ` for executing a `Manipulation` or `Query`,
1111and a `PQ` type with instances for them.
1212
1313Using Squeal in your application will come down to defining
14−the @schema@ of your database and including @PQ schema schema@ in your
14+the @db@ of your database and including @PQ db db@ in your
1515application's monad transformer stack, giving it an instance of `MonadPQ`.
1616
1717This module also provides functions for retrieving rows from the `LibPQ.Result`
@@ -130,22 +130,22 @@ Note that, for now, squeal doesn't offer any protection from connecting
130130with the wrong schema!
131131-}
132132connectdb
133− :: forall schema io
133+ :: forall db io
134134 . MonadBase IO io
135135 => ByteString -- ^ conninfo
136− -> io (K LibPQ.Connection schema)
136+ -> io (K LibPQ.Connection db)
137137connectdb = fmap K . liftBase . LibPQ.connectdb
138138
139139-- | Closes the connection to the server.
140−finish :: MonadBase IO io => K LibPQ.Connection schema -> io ()
140+finish :: MonadBase IO io => K LibPQ.Connection db -> io ()
141141finish = liftBase . LibPQ.finish . unK
142142
143143-- | Do `connectdb` and `finish` before and after a computation.
144144withConnection
145− :: forall schema0 schema1 io x
145+ :: forall db0 db1 io x
146146 . MonadBaseControl IO io
147147 => ByteString
148− -> PQ schema0 schema1 io x
148+ -> PQ db0 db1 io x
149149 -> io x
150150withConnection connString action = do
151151 K x <- bracket (connectdb connString) finish (unPQ action)
@@ -153,20 +153,20 @@ withConnection connString action = do
153153
154154-- | Safely `lowerConnection` to a smaller schema.
155155lowerConnection
156− :: K LibPQ.Connection (table ': schema)
157− -> K LibPQ.Connection schema
156+ :: K LibPQ.Connection (schema ': db)
157+ -> K LibPQ.Connection db
158158lowerConnection (K conn) = K conn
159159
160160-- | We keep track of the schema via an Atkey indexed state monad transformer,
161161-- `PQ`.
162162newtype PQ
163− (schema0 :: SchemaType)
164− (schema1 :: SchemaType)
163+ (db0 :: DBType)
164+ (db1 :: DBType)
165165 (m :: Type -> Type)
166166 (x :: Type) =
167− PQ { unPQ :: K LibPQ.Connection schema0 -> m (K x schema1) }
167+ PQ { unPQ :: K LibPQ.Connection db0 -> m (K x db1) }
168168
169−instance Monad m => Functor (PQ schema0 schema1 m) where
169+instance Monad m => Functor (PQ db0 db1 m) where
170170 fmap f (PQ pq) = PQ $ \ conn -> do
171171 K x <- pq conn
172172 return $ K (f x)
@@ -174,9 +174,9 @@ instance Monad m => Functor (PQ schema0 schema1 m) where
174174-- | Run a `PQ` and keep the result and the `Connection`.
175175runPQ
176176 :: Functor m
177− => PQ schema0 schema1 m x
178− -> K LibPQ.Connection schema0
179− -> m (x, K LibPQ.Connection schema1)
177+ => PQ db0 db1 m x
178+ -> K LibPQ.Connection db0
179+ -> m (x, K LibPQ.Connection db1)
180180runPQ (PQ pq) conn = (\ x -> (unK x, K (unK conn))) <$> pq conn
181181 -- K x <- pq conn
182182 -- return (x, K (unK conn))
@@ -184,16 +184,16 @@ runPQ (PQ pq) conn = (\ x -> (unK x, K (unK conn))) <$> pq conn
184184-- | Execute a `PQ` and discard the result but keep the `Connection`.
185185execPQ
186186 :: Functor m
187− => PQ schema0 schema1 m x
188− -> K LibPQ.Connection schema0
189− -> m (K LibPQ.Connection schema1)
187+ => PQ db0 db1 m x
188+ -> K LibPQ.Connection db0
189+ -> m (K LibPQ.Connection db1)
190190execPQ (PQ pq) conn = mapKK (\ _ -> unK conn) <$> pq conn
191191
192192-- | Evaluate a `PQ` and discard the `Connection` but keep the result.
193193evalPQ
194194 :: Functor m
195− => PQ schema0 schema1 m x
196− -> K LibPQ.Connection schema0
195+ => PQ db0 db1 m x
196+ -> K LibPQ.Connection db0
197197 -> m x
198198evalPQ (PQ pq) conn = unK <$> pq conn
199199
@@ -208,53 +208,53 @@ class IndexedMonadTransPQ pq where
208208 -- | indexed analog of `<*>`
209209 pqAp
210210 :: Monad m
211− => pq schema0 schema1 m (x -> y)
212− -> pq schema1 schema2 m x
213− -> pq schema0 schema2 m y
211+ => pq db0 db1 m (x -> y)
212+ -> pq db1 db2 m x
213+ -> pq db0 db2 m y
214214
215215 -- | indexed analog of `join`
216216 pqJoin
217217 :: Monad m
218− => pq schema0 schema1 m (pq schema1 schema2 m y)
219− -> pq schema0 schema2 m y
218+ => pq db0 db1 m (pq db1 db2 m y)
219+ -> pq db0 db2 m y
220220 pqJoin pq = pq & pqBind id
221221
222222 -- | indexed analog of `=<<`
223223 pqBind
224224 :: Monad m
225− => (x -> pq schema1 schema2 m y)
226− -> pq schema0 schema1 m x
227− -> pq schema0 schema2 m y
225+ => (x -> pq db1 db2 m y)
226+ -> pq db0 db1 m x
227+ -> pq db0 db2 m y
228228
229229 -- | indexed analog of flipped `>>`
230230 pqThen
231231 :: Monad m
232− => pq schema1 schema2 m y
233− -> pq schema0 schema1 m x
234− -> pq schema0 schema2 m y
232+ => pq db1 db2 m y
233+ -> pq db0 db1 m x
234+ -> pq db0 db2 m y
235235 pqThen pq2 pq1 = pq1 & pqBind (\ _ -> pq2)
236236
237237 -- | indexed analog of `<=<`
238238 pqAndThen
239239 :: Monad m
240− => (y -> pq schema1 schema2 m z)
241− -> (x -> pq schema0 schema1 m y)
242− -> x -> pq schema0 schema2 m z
240+ => (y -> pq db1 db2 m z)
241+ -> (x -> pq db0 db1 m y)
242+ -> x -> pq db0 db2 m z
243243 pqAndThen g f x = pqBind g (f x)
244244
245245 -- | Safely embed a computation in a larger schema.
246246 pqEmbed
247247 :: Monad m
248− => pq schema0 schema1 m x
249− -> pq (table ': schema0) (table : schema1) m x
248+ => pq db0 db1 m x
249+ -> pq (table ': db0) (table : db1) m x
250250
251251 -- | Run a `Definition` with `LibPQ.exec`, we expect that libpq obeys the law
252252 --
253253 -- @define statement1 & pqThen (define statement2) = define (statement1 >>> statement2)@
254254 define
255255 :: MonadBase IO io
256− => Definition schema0 schema1
257− -> pq schema0 schema1 io (K LibPQ.Result '[])
256+ => Definition db0 db1
257+ -> pq db0 db1 io (K LibPQ.Result '[])
258258
259259instance IndexedMonadTransPQ PQ where
260260
@@ -312,66 +312,66 @@ To define an instance, you can minimally define only `manipulateParams`,
312312a default instance.
313313
314314-}
315−class Monad pq => MonadPQ schema pq | pq -> schema where
315+class Monad pq => MonadPQ db pq | pq -> db where
316316 manipulateParams
317317 :: ToParams x params
318− => Manipulation schema params ys
318+ => Manipulation db params ys
319319 -- ^ `insertRows`, `update` or `deleteFrom`
320320 -> x -> pq (K LibPQ.Result ys)
321321 default manipulateParams
322− :: (MonadTrans t, MonadPQ schema pq1, pq ~ t pq1)
322+ :: (MonadTrans t, MonadPQ db pq1, pq ~ t pq1)
323323 => ToParams x params
324− => Manipulation schema params ys
324+ => Manipulation db params ys
325325 -- ^ `insertRows`, `update` or `deleteFrom`
326326 -> x -> pq (K LibPQ.Result ys)
327327 manipulateParams manipulation params = lift $
328328 manipulateParams manipulation params
329329
330− manipulate :: Manipulation schema '[] ys -> pq (K LibPQ.Result ys)
330+ manipulate :: Manipulation db '[] ys -> pq (K LibPQ.Result ys)
331331 manipulate statement = manipulateParams statement ()
332332
333333 runQueryParams
334334 :: ToParams x params
335− => Query schema params ys
335+ => Query db params ys
336336 -- ^ `select` and friends
337337 -> x -> pq (K LibPQ.Result ys)
338338 runQueryParams = manipulateParams . queryStatement
339339
340340 runQuery
341− :: Query schema '[] ys
341+ :: Query db '[] ys
342342 -- ^ `select` and friends
343343 -> pq (K LibPQ.Result ys)
344344 runQuery q = runQueryParams q ()
345345
346346 traversePrepared
347347 :: (ToParams x params, Traversable list)
348− => Manipulation schema params ys
348+ => Manipulation db params ys
349349 -- ^ `insertRows`, `update`, or `deleteFrom`, and friends
350350 -> list x -> pq (list (K LibPQ.Result ys))
351351 default traversePrepared
352− :: (MonadTrans t, MonadPQ schema pq1, pq ~ t pq1)
352+ :: (MonadTrans t, MonadPQ db pq1, pq ~ t pq1)
353353 => (ToParams x params, Traversable list)
354− => Manipulation schema params ys -> list x -> pq (list (K LibPQ.Result ys))
354+ => Manipulation db params ys -> list x -> pq (list (K LibPQ.Result ys))
355355 traversePrepared manipulation params = lift $
356356 traversePrepared manipulation params
357357
358358 forPrepared
359359 :: (ToParams x params, Traversable list)
360360 => list x
361− -> Manipulation schema params ys
361+ -> Manipulation db params ys
362362 -- ^ `insertRows`, `update` or `deleteFrom`
363363 -> pq (list (K LibPQ.Result ys))
364364 forPrepared = flip traversePrepared
365365
366366 traversePrepared_
367367 :: (ToParams x params, Foldable list)
368− => Manipulation schema params '[]
368+ => Manipulation db params '[]
369369 -- ^ `insertRows`, `update` or `deleteFrom`
370370 -> list x -> pq ()
371371 default traversePrepared_
372− :: (MonadTrans t, MonadPQ schema pq1, pq ~ t pq1)
372+ :: (MonadTrans t, MonadPQ db pq1, pq ~ t pq1)
373373 => (ToParams x params, Foldable list)
374− => Manipulation schema params '[]
374+ => Manipulation db params '[]
375375 -- ^ `insertRows`, `update` or `deleteFrom`
376376 -> list x -> pq ()
377377 traversePrepared_ manipulation params = lift $
@@ -380,22 +380,22 @@ class Monad pq => MonadPQ schema pq | pq -> schema where
380380 forPrepared_
381381 :: (ToParams x params, Foldable list)
382382 => list x
383− -> Manipulation schema params '[]
383+ -> Manipulation db params '[]
384384 -- ^ `insertRows`, `update` or `deleteFrom`
385385 -> pq ()
386386 forPrepared_ = flip traversePrepared_
387387
388388 liftPQ :: (LibPQ.Connection -> IO a) -> pq a
389389 default liftPQ
390− :: (MonadTrans t, MonadPQ schema pq1, pq ~ t pq1)
390+ :: (MonadTrans t, MonadPQ db pq1, pq ~ t pq1)
391391 => (LibPQ.Connection -> IO a) -> pq a
392392 liftPQ = lift . liftPQ
393393
394−instance (MonadBase IO io, schema0 ~ schema, schema1 ~ schema)
395− => MonadPQ schema (PQ schema0 schema1 io) where
394+instance (MonadBase IO io, db0 ~ db, db1 ~ db)
395+ => MonadPQ db (PQ db0 db1 io) where
396396
397397 manipulateParams
398− (UnsafeManipulation q :: Manipulation schema ps ys) (params :: x) =
398+ (UnsafeManipulation q :: Manipulation db ps ys) (params :: x) =
399399 PQ $ \ (K conn) -> do
400400 let
401401 toParam' encoding =
@@ -411,7 +411,7 @@ instance (MonadBase IO io, schema0 ~ schema, schema1 ~ schema)
411411 return $ K (K result)
412412
413413 traversePrepared
414− (UnsafeManipulation q :: Manipulation schema xs ys) (list :: list x) =
414+ (UnsafeManipulation q :: Manipulation db xs ys) (list :: list x) =
415415 PQ $ \ (K conn) -> liftBase $ do
416416 let temp = "temporary_statement"
417417 prepResultMaybe <- LibPQ.prepare conn temp q Nothing
@@ -438,7 +438,7 @@ instance (MonadBase IO io, schema0 ~ schema, schema1 ~ schema)
438438 return (K results)
439439
440440 traversePrepared_
441− (UnsafeManipulation q :: Manipulation schema xs '[]) (list :: list x) =
441+ (UnsafeManipulation q :: Manipulation db xs '[]) (list :: list x) =
442442 PQ $ \ (K conn) -> liftBase $ do
443443 let temp = "temporary_statement"
444444 prepResultMaybe <- LibPQ.prepare conn temp q Nothing
@@ -466,56 +466,56 @@ instance (MonadBase IO io, schema0 ~ schema, schema1 ~ schema)
466466 y <- liftBase $ pq conn
467467 return (K y)
468468
469−instance MonadPQ schema m => MonadPQ schema (IdentityT m)
470−instance MonadPQ schema m => MonadPQ schema (ReaderT r m)
471−instance MonadPQ schema m => MonadPQ schema (Strict.StateT s m)
472−instance MonadPQ schema m => MonadPQ schema (Lazy.StateT s m)
473−instance (Monoid w, MonadPQ schema m) => MonadPQ schema (Strict.WriterT w m)
474−instance (Monoid w, MonadPQ schema m) => MonadPQ schema (Lazy.WriterT w m)
475−instance MonadPQ schema m => MonadPQ schema (MaybeT m)
476−instance MonadPQ schema m => MonadPQ schema (ExceptT e m)
477−instance (Monoid w, MonadPQ schema m) => MonadPQ schema (Strict.RWST r w s m)
478−instance (Monoid w, MonadPQ schema m) => MonadPQ schema (Lazy.RWST r w s m)
479−instance MonadPQ schema m => MonadPQ schema (ContT r m)
480−
481−instance (Monad m, schema0 ~ schema1)
482− => Applicative (PQ schema0 schema1 m) where
469+instance MonadPQ db m => MonadPQ db (IdentityT m)
470+instance MonadPQ db m => MonadPQ db (ReaderT r m)
471+instance MonadPQ db m => MonadPQ db (Strict.StateT s m)
472+instance MonadPQ db m => MonadPQ db (Lazy.StateT s m)
473+instance (Monoid w, MonadPQ db m) => MonadPQ db (Strict.WriterT w m)
474+instance (Monoid w, MonadPQ db m) => MonadPQ db (Lazy.WriterT w m)
475+instance MonadPQ db m => MonadPQ db (MaybeT m)
476+instance MonadPQ db m => MonadPQ db (ExceptT e m)
477+instance (Monoid w, MonadPQ db m) => MonadPQ db (Strict.RWST r w s m)
478+instance (Monoid w, MonadPQ db m) => MonadPQ db (Lazy.RWST r w s m)
479+instance MonadPQ db m => MonadPQ db (ContT r m)
480+
481+instance (Monad m, db0 ~ db1)
482+ => Applicative (PQ db0 db1 m) where
483483 pure x = PQ $ \ _conn -> pure (K x)
484484 (<*>) = pqAp
485485
486−instance (Monad m, schema0 ~ schema1)
487− => Monad (PQ schema0 schema1 m) where
486+instance (Monad m, db0 ~ db1)
487+ => Monad (PQ db0 db1 m) where
488488 return = pure
489489 (>>=) = flip pqBind
490490
491−instance schema0 ~ schema1 => MFunctor (PQ schema0 schema1) where
491+instance db0 ~ db1 => MFunctor (PQ db0 db1) where
492492 hoist f (PQ pq) = PQ (f . pq)
493493
494−instance schema0 ~ schema1 => MonadTrans (PQ schema0 schema1) where
494+instance db0 ~ db1 => MonadTrans (PQ db0 db1) where
495495 lift m = PQ $ \ _conn -> do
496496 x <- m
497497 return (K x)
498498
499−instance schema0 ~ schema1 => MMonad (PQ schema0 schema1) where
499+instance db0 ~ db1 => MMonad (PQ db0 db1) where
500500 embed f (PQ pq) = PQ $ \ conn -> do
501501 evalPQ (f (pq conn)) conn
502502
503−instance (MonadBase b m, schema0 ~ schema1)
504− => MonadBase b (PQ schema0 schema1 m) where
503+instance (MonadBase b m, db0 ~ db1)
504+ => MonadBase b (PQ db0 db1 m) where
505505 liftBase = lift . liftBase
506506
507507-- | A snapshot of the state of a `PQ` computation.
508−type PQRun schema =
509− forall m x. Monad m => PQ schema schema m x -> m (K x schema)
508+type PQRun db =
509+ forall m x. Monad m => PQ db db m x -> m (K x db)
510510
511511-- | Helper function in defining `MonadBaseControl` instance for `PQ`.
512−pqliftWith :: Functor m => (PQRun schema -> m a) -> PQ schema schema m a
512+pqliftWith :: Functor m => (PQRun db -> m a) -> PQ db db m a
513513pqliftWith f = PQ $ \ conn ->
514514 fmap K (f $ \ pq -> unPQ pq conn)
515515
516−instance (MonadBaseControl b m, schema0 ~ schema1)
517− => MonadBaseControl b (PQ schema0 schema1 m) where
518− type StM (PQ schema0 schema1 m) x = StM m (K x schema0)
516+instance (MonadBaseControl b m, db0 ~ db1)
517+ => MonadBaseControl b (PQ db0 db1 m) where
518+ type StM (PQ db0 db1 m) x = StM m (K x db0)
519519 liftBaseWith f =
520520 pqliftWith $ \ run -> liftBaseWith $ \ runInBase -> f $ runInBase . run
521521 restoreM = PQ . const . restoreM
squeal-postgresql/src/Squeal/PostgreSQL/Pool.hs+18−18
@@ -41,7 +41,7 @@ import Generics.SOP (K(..))
4141import Squeal.PostgreSQL.PQ
4242import Squeal.PostgreSQL.Schema
4343
44−{- | `PoolPQ` @schema@ should be a drop-in replacement for `PQ` @schema schema@.
44+{- | `PoolPQ` @db@ should be a drop-in replacement for `PQ` @db db@.
4545
4646Typical use case would be to create your pool using `createConnectionPool` and run anything that requires the pool connection with it.
4747
@@ -63,8 +63,8 @@ Here's a simplified example:
6363> liftIO $ runPoolPQ (insertOne) pool
6464
6565-}
66−newtype PoolPQ (schema :: SchemaType) m x =
67− PoolPQ { runPoolPQ :: Pool (K Connection schema) -> m x }
66+newtype PoolPQ (db :: DBType) m x =
67+ PoolPQ { runPoolPQ :: Pool (K Connection db) -> m x }
6868 deriving Functor
6969
7070-- | Create a striped pool of connections.
@@ -86,12 +86,12 @@ createConnectionPool
8686 -> Int
8787 -- ^ Maximum number of connections to keep open per stripe. The smallest acceptable value is 1.
8888 -- Requests for connections will block if this limit is reached on a single stripe, even if other stripes have idle connections available.
89− -> io (Pool (K Connection schema))
89+ -> io (Pool (K Connection db))
9090createConnectionPool conninfo stripes idle maxResrc = liftBase $
9191 createPool (connectdb conninfo) finish stripes idle maxResrc
9292
9393-- | `Applicative` instance for `PoolPQ`.
94−instance Monad m => Applicative (PoolPQ schema m) where
94+instance Monad m => Applicative (PoolPQ db m) where
9595 pure x = PoolPQ $ \ _ -> pure x
9696 PoolPQ f <*> PoolPQ x = PoolPQ $ \ pool -> do
9797 f' <- f pool
@@ -99,55 +99,55 @@ instance Monad m => Applicative (PoolPQ schema m) where
9999 return $ f' x'
100100
101101-- | `Monad` instance for `PoolPQ`.
102−instance Monad m => Monad (PoolPQ schema m) where
102+instance Monad m => Monad (PoolPQ db m) where
103103 return = pure
104104 PoolPQ x >>= f = PoolPQ $ \ pool -> do
105105 x' <- x pool
106106 runPoolPQ (f x') pool
107107
108108-- | `MonadTrans` instance for `PoolPQ`.
109−instance MonadTrans (PoolPQ schema) where
109+instance MonadTrans (PoolPQ db) where
110110 lift m = PoolPQ $ \ _pool -> m
111111
112112-- | `MonadBase` instance for `PoolPQ`.
113−instance MonadBase b m => MonadBase b (PoolPQ schema m) where
113+instance MonadBase b m => MonadBase b (PoolPQ db m) where
114114 liftBase = lift . liftBase
115115
116116-- | `MonadPQ` instance for `PoolPQ`.
117−instance MonadBaseControl IO io => MonadPQ schema (PoolPQ schema io) where
117+instance MonadBaseControl IO io => MonadPQ db (PoolPQ db io) where
118118 manipulateParams manipulation params = PoolPQ $ \ pool -> do
119119 withResource pool $ \ conn -> do
120− (K result :: K (K Result ys) schema) <- flip unPQ conn $
120+ (K result :: K (K Result ys) db) <- flip unPQ conn $
121121 manipulateParams manipulation params
122122 return result
123123 traversePrepared manipulation params = PoolPQ $ \ pool ->
124124 withResource pool $ \ conn -> do
125− (K result :: K (list (K Result ys)) schema) <- flip unPQ conn $
125+ (K result :: K (list (K Result ys)) db) <- flip unPQ conn $
126126 traversePrepared manipulation params
127127 return result
128128 traversePrepared_ manipulation params = PoolPQ $ \ pool -> do
129129 withResource pool $ \ conn -> do
130− (_ :: K () schema) <- flip unPQ conn $
130+ (_ :: K () db) <- flip unPQ conn $
131131 traversePrepared_ manipulation params
132132 return ()
133133 liftPQ m = PoolPQ $ \ pool ->
134134 withResource pool $ \ conn -> do
135− (K result :: K result schema) <- flip unPQ conn $
135+ (K result :: K result db) <- flip unPQ conn $
136136 liftPQ m
137137 return result
138138
139139-- | A snapshot of the state of a `PoolPQ` computation.
140−type PoolPQRun schema =
141− forall m x. Monad m => PoolPQ schema m x -> m x
140+type PoolPQRun db =
141+ forall m x. Monad m => PoolPQ db m x -> m x
142142
143143-- | Helper function in defining `MonadBaseControl` instance for `PoolPQ`.
144−poolpqliftWith :: Functor m => (PoolPQRun schema -> m a) -> PoolPQ schema m a
144+poolpqliftWith :: Functor m => (PoolPQRun db -> m a) -> PoolPQ db m a
145145poolpqliftWith f = PoolPQ $ \ pool ->
146146 (f $ \ pq -> runPoolPQ pq pool)
147147
148148-- | `MonadBaseControl` instance for `PoolPQ`.
149−instance MonadBaseControl b m => MonadBaseControl b (PoolPQ schema m) where
150− type StM (PoolPQ schema m) x = StM m x
149+instance MonadBaseControl b m => MonadBaseControl b (PoolPQ db m) where
150+ type StM (PoolPQ db m) x = StM m x
151151 liftBaseWith f =
152152 poolpqliftWith $ \ run -> liftBaseWith $ \ runInBase -> f $ runInBase . run
153153 restoreM = PoolPQ . const . restoreM
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+11−11
@@ -853,31 +853,31 @@ FROM clauses
853853A `FromClause` can be a table name, or a derived table such
854854as a subquery, a @JOIN@ construct, or complex combinations of these.
855855-}
856−newtype FromClause schema params from
856+newtype FromClause db params from
857857 = UnsafeFromClause { renderFromClause :: ByteString }
858858 deriving (GHC.Generic,Show,Eq,Ord,NFData)
859859
860860-- | A real `table` is a table from the schema.
861861table
862− :: Has tab schema ('Table table)
863− => Aliased Alias (alias ::: tab)
864− -> FromClause schema params '[alias ::: TableToRow table]
862+ :: HasQualified sch tab db schema ('Table table)
863+ => Aliased (QualifiedAlias sch) (alias ::: tab)
864+ -> FromClause db params '[alias ::: TableToRow table]
865865table (tab `As` alias) = UnsafeFromClause $
866− renderAlias tab <+> "AS" <+> renderAlias alias
866+ renderQualifiedAlias tab <+> "AS" <+> renderAlias alias
867867
868868-- | `subquery` derives a table from a `Query`.
869869subquery
870− :: Aliased (Query db params) rel
871− -> FromClause schema params '[rel]
870+ :: Aliased (Query db params) query
871+ -> FromClause schema params '[query]
872872subquery = UnsafeFromClause . renderAliasedAs (parenthesized . renderQuery)
873873
874874-- | `view` derives a table from a `View`.
875875view
876− :: Has view schema ('View row)
877− => Aliased Alias (alias ::: view)
878− -> FromClause schema params '[alias ::: row]
876+ :: HasQualified sch vw db schema ('View view)
877+ => Aliased (QualifiedAlias sch) (alias ::: vw)
878+ -> FromClause db params '[alias ::: view]
879879view (vw `As` alias) = UnsafeFromClause $
880− renderAlias vw <+> "AS" <+> renderAlias alias
880+ renderQualifiedAlias vw <+> "AS" <+> renderAlias alias
881881
882882{- | @left & crossJoin right@. For every possible combination of rows from
883883 @left@ and @right@ (i.e., a Cartesian product), the joined table will contain