Fix support for "return ()" inside a select.
This commit is contained in:
parent
f6969d5971
commit
f0ae243f5f
@ -707,13 +707,15 @@ uncommas' = (uncommas *** mconcat) . unzip
|
|||||||
|
|
||||||
|
|
||||||
makeSelect :: SqlSelect a r => Connection -> Mode -> a -> (TLB.Builder, [PersistValue])
|
makeSelect :: SqlSelect a r => Connection -> Mode -> a -> (TLB.Builder, [PersistValue])
|
||||||
makeSelect conn mode ret = first (s <>) (sqlSelectCols conn ret)
|
makeSelect conn mode ret =
|
||||||
|
case mode of
|
||||||
|
SELECT -> withCols "SELECT "
|
||||||
|
SELECT_DISTINCT -> withCols "SELECT DISTINCT "
|
||||||
|
DELETE -> plain "DELETE "
|
||||||
|
UPDATE -> plain "UPDATE "
|
||||||
where
|
where
|
||||||
s = case mode of
|
withCols v = first (v <>) (sqlSelectCols conn ret)
|
||||||
SELECT -> "SELECT "
|
plain v = (v, [])
|
||||||
SELECT_DISTINCT -> "SELECT DISTINCT "
|
|
||||||
DELETE -> "DELETE"
|
|
||||||
UPDATE -> "UPDATE "
|
|
||||||
|
|
||||||
|
|
||||||
makeFrom :: Connection -> Mode -> [FromClause] -> (TLB.Builder, [PersistValue])
|
makeFrom :: Connection -> Mode -> [FromClause] -> (TLB.Builder, [PersistValue])
|
||||||
@ -831,8 +833,8 @@ class SqlSelect a r | a -> r, r -> a where
|
|||||||
|
|
||||||
-- | Not useful for 'select', but used for 'update' and 'delete'.
|
-- | Not useful for 'select', but used for 'update' and 'delete'.
|
||||||
instance SqlSelect () () where
|
instance SqlSelect () () where
|
||||||
sqlSelectCols _ _ = mempty
|
sqlSelectCols _ _ = ("1", [])
|
||||||
sqlSelectColCount _ = 0
|
sqlSelectColCount _ = 1
|
||||||
sqlSelectProcessRow _ = Right ()
|
sqlSelectProcessRow _ = Right ()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -60,6 +60,11 @@ main = do
|
|||||||
ret <- select $ return (val (3 :: Int), ())
|
ret <- select $ return (val (3 :: Int), ())
|
||||||
liftIO $ ret `shouldBe` [ (Value 3, ()) ]
|
liftIO $ ret `shouldBe` [ (Value 3, ()) ]
|
||||||
|
|
||||||
|
it "works for a single ()" $
|
||||||
|
run $ do
|
||||||
|
ret <- select $ return ()
|
||||||
|
liftIO $ ret `shouldBe` [ () ]
|
||||||
|
|
||||||
it "works for a single NULL value" $
|
it "works for a single NULL value" $
|
||||||
run $ do
|
run $ do
|
||||||
ret <- select $ return $ nothing
|
ret <- select $ return $ nothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user