on master help sign in
Document values
commitfce7213726ded01ea9d13fb6fd10ac106158d24e authorOllie Charles <ollie@ocharles.org.uk> dateTue 23 Mar 2021, 16:22 (6 years ago) parentf0744d2
1 file changed+9
src/Rel8/Query/Values.hs+9
src/Rel8/Query/Values.hs+9
@@ -20,5 +20,14 @@ import Rel8.Table.Opaleye ( valuesspec )
2020import Rel8.Schema.Context ( DB )
2121
2222
23+-- | Construct a query that returns the given input list of rows. This is like
24+-- folding a list of 'return' statements under 'union', but uses the SQL
25+-- @VALUES@ expression for efficiency.
26+--
27+-- Typically @values@ will be used with 'lit':
28+--
29+-- >>> mapM_ Data.Text.IO.putStrLn =<< select c (values [ lit "Hello", lit "World!" ])
30+-- Hello
31+-- World!
2332values :: (Table DB a, Foldable f) => f a -> Query a
2433values = fromOpaleye . Opaleye.valuesExplicit valuesspec . toList