groundhog-0.3.0: Type-safe datatype-database mapping library.

Safe HaskellNone




This module defines the functions which are used only for backends creation.


SQL rendering utilities



:: forall r db . (SqlDb db, QueryRaw db ~ Snippet db) 
=> (Utf8 -> Utf8)


-> (Utf8 -> Utf8 -> Utf8)

render equals

-> (Utf8 -> Utf8 -> Utf8)

render not equals

-> Cond db r 
-> Maybe (RenderS db r) 

Renders conditions for SQL backend. Returns Nothing if the fields don't have any columns.

renderOrders :: forall db r. (Utf8 -> Utf8) -> [Order db r] -> Utf8Source

renderUpdates :: (SqlDb db, QueryRaw db ~ Snippet db) => (Utf8 -> Utf8) -> [Update db r] -> Maybe (RenderS db r)Source

renderExpr :: (DbDescriptor db, QueryRaw db ~ Snippet db) => (Utf8 -> Utf8) -> UntypedExpr db r -> RenderS db rSource

renderExprExtended :: (DbDescriptor db, QueryRaw db ~ Snippet db) => (Utf8 -> Utf8) -> Int -> UntypedExpr db r -> [RenderS db r]Source

intercalateS :: StringLike s => s -> [s] -> sSource

commasJoin :: StringLike s => [s] -> sSource

data RenderS db r Source




IsString (RenderS db r) 
Monoid (RenderS db r) 
StringLike (RenderS db r) 

newtype Utf8 Source

Datatype for incremental building SQL queries


Utf8 Builder 

class (Monoid a, IsString a) => StringLike a whereSource


fromChar :: Char -> aSource

(<>) :: Monoid m => m -> m -> m

An infix synonym for mappend.

function :: (SqlDb db, QueryRaw db ~ Snippet db) => String -> [UntypedExpr db r] -> Snippet db rSource

operator :: (SqlDb db, QueryRaw db ~ Snippet db, Expression db r a, Expression db r b) => Int -> String -> a -> b -> Snippet db rSource

parens :: Int -> Int -> RenderS db r -> RenderS db rSource

newtype Snippet db r Source

Escape function, priority of the outer operator. The result is a list for the embedded data which may expand to several RenderS.


Snippet ((Utf8 -> Utf8) -> Int -> [RenderS db r]) 

class DbDescriptor db => SqlDb db whereSource

This class distinguishes databases which support SQL-specific expressions. It contains ad hoc members for features whose syntax differs across the databases.


append :: (ExpressionOf db r a String, ExpressionOf db r b String) => a -> b -> Expr db r StringSource

liftExpr :: (SqlDb db, QueryRaw db ~ Snippet db, ExpressionOf db r a b) => a -> Expr db r bSource

tableName :: StringLike s => (s -> s) -> EntityDef -> ConstructorDef -> sSource

Returns escaped table name optionally qualified with schema

mainTableName :: StringLike s => (s -> s) -> EntityDef -> sSource

Returns escaped main table name optionally qualified with schema