@@ -96,8 +96,11 @@ instance (KnownSymbol label, AllAliased (x' ': xs))
96 (x :& xs :: Rec (Aliased obj) ('(label, x) ': x' : xs)) =
96 (x :& xs :: Rec (Aliased obj) ('(label, x) ': x' : xs)) =
97 renderAliased render x <> ", " <> renderAllAliased render xs
97 renderAliased render x <> ", " <> renderAllAliased render xs
99−newtype Expression ps (xs :: [(Symbol,PGType)]) y =
99+newtype Expression
101+ (xs :: [(Symbol,PGType)])
100− UnsafeExpression { renderExpression :: ByteString }
103+ UnsafeExpression { renderExpression :: ByteString }
102param1 :: Expression (p1:ps) cols p1
105param1 :: Expression (p1:ps) cols p1
103param1 = UnsafeExpression "$1"
106param1 = UnsafeExpression "$1"
@@ -170,8 +173,11 @@ instance OrdB (Expression ps xs y) where
170 x <* y = UnsafeExpression $ renderExpression x <> "<" <> renderExpression y
173 x <* y = UnsafeExpression $ renderExpression x <> "<" <> renderExpression y
171 x <=* y = UnsafeExpression $ renderExpression x <> "<=" <> renderExpression y
174 x <=* y = UnsafeExpression $ renderExpression x <> "<=" <> renderExpression y
173−newtype Projection ps xs ys = UnsafeProjection
176+newtype Projection
178+ (xs :: [(Symbol,PGType)])
179+ (ys :: [(Symbol,PGType)]) =
174− { renderProjection :: ByteString }
180+ UnsafeProjection { renderProjection :: ByteString }
176star :: Projection ps xs xs
182star :: Projection ps xs xs
177star = UnsafeProjection "*"
183star = UnsafeProjection "*"
@@ -254,33 +260,31 @@ subselect selection = Relation
254 , offsetting = Nothing
260 , offsetting = Nothing
257−newtype Insertion ps xss xs = UnsafeInsertion
263+newtype Query
258− {renderInsertion :: ByteString }
264+ (ps :: [PGType])
265+ (xss :: [(Symbol,[(Symbol,PGType)])])
266+ (yss :: [(Symbol,[(Symbol,PGType)])])
267+ (zs :: [(Symbol,PGType)]) =
268+ UnsafeQuery { renderQuery :: ByteString }
269+newtype PreparedQuery ps xss yss zs =
270+ UnsafePreparedQuery { renderPreparedQuery :: ByteString }
260−into
272+select :: Selection ps xss ys -> Query ps xss xss ys
273+select selection = UnsafeQuery $
274+ "SELECT " <> renderSelection selection <> ";"
261− :: forall label xss xs ps
277+ :: forall xss xs label ps
262 . (HasField label xss xs, UnzipAliased xs)
278 . (HasField label xss xs, UnzipAliased xs)
263 => Proxy label
279 => Proxy label
264 -> Rec (Aliased (Expression ps '[])) xs
280 -> Rec (Aliased (Expression ps '[])) xs
265− -> Insertion ps xss xs
281+ -> Query ps xss xss '[]
266−into table values = UnsafeInsertion $ "INTO "
282+insertInto table values = UnsafeQuery $ "INSERT INTO "
267 <> fieldName table (Proxy @xss) (Proxy @xs)
283 <> fieldName table (Proxy @xss) (Proxy @xs)
268 <> " (" <> ByteString.intercalate ", " names
284 <> " (" <> ByteString.intercalate ", " names
269 <> ") VALUES ("
285 <> ") VALUES ("
270 <> ByteString.intercalate ", "
286 <> ByteString.intercalate ", "
271 (recordToList (rmap (Const . renderExpression) exprs))
287 (recordToList (rmap (Const . renderExpression) exprs))
274 (names,exprs) = unzipAliased values
290 (names,exprs) = unzipAliased values
276−newtype Query ps xss yss zs = UnsafeQuery { renderQuery :: ByteString }
277−newtype PreparedQuery ps xss yss zs =
278− UnsafePreparedQuery { renderPreparedQuery :: ByteString }
280−select :: Selection ps xss ys -> Query ps xss xss ys
281−select selection = UnsafeQuery $
282− "SELECT " <> renderSelection selection <> ";"
284−insert :: Insertion ps xss xs -> Query ps xss xss '[]
285−insert insertion = UnsafeQuery $
286− "INSERT " <> renderInsertion insertion <> ";"