beam-core-0.10.0.0: Type-safe, feature-complete SQL query and manipulation interface for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.Beam.Backend.SQL

Synopsis

Documentation

class (BeamBackend be, Monad m) => MonadBeam be m | m -> be where Source #

A class that ties together a monad with a particular backend

Provided here is a low-level interface for executing commands. The 'run*' functions are wrapped by the appropriate functions in Query.

This interface is very high-level and isn't meant to expose the full power of the underlying database. Namely, it only supports simple data retrieval strategies. More complicated strategies (for example, Postgres's COPY) are supported in individual backends. See the documentation of those backends for more details.

Minimal complete definition

runReturningMany

Methods

runReturningMany Source #

Arguments

:: FromBackendRow be x 
=> BeamSqlBackendSyntax be

The query to run

-> (m (Maybe x) -> m a)

Reader action that will be called with a function to fetch the next row

-> m a 

Run a query determined by the given syntax, providing an action that will be called to consume the results from the database (if any). The action will get a reader action that can be used to fetch the next row. When this reader action returns Nothing, there are no rows left to consume. When the reader action returns, the database result is freed.

runNoReturn :: BeamSqlBackendSyntax be -> m () Source #

Run the given command and don't consume any results. Useful for DML statements like INSERT, UPDATE, and DELETE, or DDL statements.

runReturningOne :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x) Source #

Run the given command and fetch the unique result. The result is Nothing if either no results are returned or more than one result is returned.

runReturningFirst :: FromBackendRow be x => BeamSqlBackendSyntax be -> m (Maybe x) Source #

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.

runReturningList :: FromBackendRow be x => BeamSqlBackendSyntax be -> m [x] Source #

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.

Instances

Instances details
MonadBeam be m => MonadBeam be (ExceptT e m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

MonadBeam be m => MonadBeam be (ReaderT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

MonadBeam be m => MonadBeam be (StateT s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

MonadBeam be m => MonadBeam be (StateT s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

(MonadBeam be m, Monoid s) => MonadBeam be (WriterT s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

(MonadBeam be m, Monoid s) => MonadBeam be (WriterT s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

MonadBeam be m => MonadBeam be (ContT r m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

(MonadBeam be m, Monoid w) => MonadBeam be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

(MonadBeam be m, Monoid w) => MonadBeam be (RWST r w s m) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

type family BeamSqlBackendSyntax be :: Type Source #

Instances

Instances details
type BeamSqlBackendSyntax (MockSqlBackend syntax) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

type BeamSqlBackendSyntax (MockSqlBackend syntax) = syntax

data MockSqlBackend syntax Source #

Fake backend that cannot deserialize anything, but is useful for testing

Instances

Instances details
BeamSqlBackendIsString (MockSqlBackend cmd :: Type) Text Source # 
Instance details

Defined in Database.Beam.Backend.SQL

BeamSqlBackendIsString (MockSqlBackend cmd :: Type) [Char] Source # 
Instance details

Defined in Database.Beam.Backend.SQL

(IsSql92Syntax syntax, Sql92SanityCheck syntax, HasSqlValueSyntax (Sql92ValueSyntax syntax) Bool, HasSqlValueSyntax (Sql92ValueSyntax syntax) SqlNull, Eq (Sql92ExpressionSyntax syntax)) => BeamSqlBackend (MockSqlBackend syntax) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

BeamBackend (MockSqlBackend syntax) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

Associated Types

type BackendFromField (MockSqlBackend syntax) :: Type -> Constraint Source #

BeamSqlBackend (MockSqlBackend cmd) => HasQBuilder (MockSqlBackend cmd) Source # 
Instance details

Defined in Database.Beam.Query.Types

Methods

buildSqlQuery :: forall a (db :: (Type -> Type) -> Type) s. Projectible (MockSqlBackend cmd) a => TablePrefix -> Q (MockSqlBackend cmd) db s a -> BeamSqlBackendSelectSyntax (MockSqlBackend cmd) Source #

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlEqualityCheck (MockSqlBackend cmd) Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word16 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word32 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word64 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word8 Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Text Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Day Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) UTCTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) LocalTime Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) TimeOfDay Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Integer Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Bool Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Double Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Float Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Int Source # 
Instance details

Defined in Database.Beam.Query.Ord

BeamSqlBackend (MockSqlBackend cmd) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) Word Source # 
Instance details

Defined in Database.Beam.Query.Ord

(BeamSqlBackend (MockSqlBackend cmd), HasSqlEqualityCheck (MockSqlBackend cmd) a) => HasSqlEqualityCheck (MockSqlBackend cmd) (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

(BeamSqlBackend (MockSqlBackend cmd), HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) a) => HasSqlQuantifiedEqualityCheck (MockSqlBackend cmd) (Tagged t a) Source # 
Instance details

Defined in Database.Beam.Query.Ord

type BeamSqlBackendSyntax (MockSqlBackend syntax) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

type BeamSqlBackendSyntax (MockSqlBackend syntax) = syntax
type BackendFromField (MockSqlBackend syntax) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

class BeamSqlBackendIsString be text Source #

Type class for things which are text-like in this backend

Instances

Instances details
BeamSqlBackendIsString be t => BeamSqlBackendIsString (be :: k1) (Tagged tag t :: Type) Source # 
Instance details

Defined in Database.Beam.Backend.SQL

BeamSqlBackendIsString (MockSqlBackend cmd :: Type) Text Source # 
Instance details

Defined in Database.Beam.Backend.SQL

BeamSqlBackendIsString (MockSqlBackend cmd :: Type) [Char] Source # 
Instance details

Defined in Database.Beam.Backend.SQL