From 0ee3461ff08a2b65e46c78d9616bd209bf3c6d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Kaminski?= Date: Wed, 10 May 2023 10:59:03 +0200 Subject: [PATCH] [Cursor] add a ToField instance Related to https://github.com/haskellari/postgresql-simple/issues/113 --- src/Database/PostgreSQL/Simple/Cursor.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Database/PostgreSQL/Simple/Cursor.hs b/src/Database/PostgreSQL/Simple/Cursor.hs index 85babd9..251fb11 100644 --- a/src/Database/PostgreSQL/Simple/Cursor.hs +++ b/src/Database/PostgreSQL/Simple/Cursor.hs @@ -29,14 +29,18 @@ import Control.Monad (unless, void) import Data.Monoid (mconcat) import Database.PostgreSQL.Simple.Compat ((<>), toByteString) import Database.PostgreSQL.Simple.FromRow (FromRow(..)) -import Database.PostgreSQL.Simple.Types (Query(..)) +import Database.PostgreSQL.Simple.ToField (ToField(..)) +import Database.PostgreSQL.Simple.Types (Identifier(..), Query(..)) import Database.PostgreSQL.Simple.Internal as Base hiding (result, row) import Database.PostgreSQL.Simple.Internal.PQResultUtils import Database.PostgreSQL.Simple.Transaction import qualified Database.PostgreSQL.LibPQ as PQ +import qualified Data.Text.Encoding as T -- | Cursor within a transaction. data Cursor = Cursor !Query !Connection +instance ToField Cursor where + toField (Cursor name _conn) = toField $ Identifier $ T.decodeUtf8 $ fromQuery name -- | Declare a temporary cursor. The cursor is given a -- unique name for the given connection.