on 269974e help sign in
rel8/src/Rel8/Query/Values.hs
27 lines 700 B history raw
1{-# language FlexibleContexts #-}
3module Rel8.Query.Values
4 ( values
5 )
6where
8-- base
9import Data.Foldable ( toList )
10import Prelude
12-- opaleye
13import qualified Opaleye.Values as Opaleye
15-- rel8
16import Rel8.Expr ( Expr )
17import {-# SOURCE #-} Rel8.Query ( Query )
18import Rel8.Query.Opaleye ( fromOpaleye )
19import Rel8.Table ( Table )
20import Rel8.Table.Opaleye ( valuesspec )
23-- | Construct a query that returns the given input list of rows. This is like
24-- folding a list of 'return' statements under 'Rel8.union', but uses the SQL
25-- @VALUES@ expression for efficiency.
26values :: (Table Expr a, Foldable f) => f a -> Query a
27values = fromOpaleye . Opaleye.valuesExplicit valuesspec . toList