hasql-notifications 0.1.0.0 → 0.2.0.0
raw patch · 4 files changed
+15/−14 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Hasql.Notifications: fromPgIdentifier :: PgIdentifier -> ByteString
+ Hasql.Notifications: fromPgIdentifier :: PgIdentifier -> Text
Files
- README.md +3/−2
- hasql-notifications.cabal +2/−2
- src/Hasql/Notifications.hs +9/−9
- test/Hasql/NotificationsSpec.hs +1/−1
README.md view
@@ -1,5 +1,6 @@ # hasql-notifications -[](https://circleci.com/gh/diogob/hasql-notifications)++[](https://matrix.hackage.haskell.org/package/postgres-websockets) -TBD+See documentation for the module [Hasql.Notifications](https://hackage.haskell.org/package/hasql-notifications/docs/Hasql-Notifications.html) on the [Hackage page](https://hackage.haskell.org/package/hasql-notifications).
hasql-notifications.cabal view
@@ -1,8 +1,8 @@ name: hasql-notifications-version: 0.1.0.0+version: 0.2.0.0 synopsis: LISTEN/NOTIFY support for Hasql description: Use PostgreSQL Asynchronous notification support with your Hasql Types.-homepage: https://github.com/githubuser/hasql-notifications#readme+homepage: https://github.com/diogob/hasql-notifications license: BSD3 license-file: LICENSE author: Diogo Biazus
src/Hasql/Notifications.hs view
@@ -33,8 +33,8 @@ import Control.Concurrent (threadWaitRead) import Control.Exception (Exception, throw) --- | A wrapped bytestring that represents a properly escaped and quoted PostgreSQL identifier-newtype PgIdentifier = PgIdentifier ByteString deriving (Show)+-- | A wrapped text that represents a properly escaped and quoted PostgreSQL identifier+newtype PgIdentifier = PgIdentifier Text deriving (Show) -- | Uncatchable exceptions thrown and never caught. newtype FatalError = FatalError { fatalErrorMessage :: String }@@ -42,14 +42,14 @@ instance Exception FatalError --- | Given a PgIdentifier returns the wrapped bytestring-fromPgIdentifier :: PgIdentifier -> ByteString+-- | Given a PgIdentifier returns the wrapped text+fromPgIdentifier :: PgIdentifier -> Text fromPgIdentifier (PgIdentifier bs) = bs --- | Given a bytestring returns a properly quoted and escaped PgIdentifier+-- | Given a text returns a properly quoted and escaped PgIdentifier toPgIdentifier :: Text -> PgIdentifier toPgIdentifier x =- PgIdentifier $ "\"" <> T.encodeUtf8 (strictlyReplaceQuotes x) <> "\""+ PgIdentifier $ "\"" <> strictlyReplaceQuotes x <> "\"" where strictlyReplaceQuotes :: Text -> Text strictlyReplaceQuotes = T.replace "\"" ("\"\"" :: Text)@@ -71,7 +71,7 @@ -> Text -- ^ Payload to be sent with the notification -> IO (Either S.QueryError ()) notify con channel mesg =- run (sql ("NOTIFY " <> fromPgIdentifier channel <> ", '" <> T.encodeUtf8 mesg <> "'")) con+ run (sql $ T.encodeUtf8 ("NOTIFY " <> fromPgIdentifier channel <> ", '" <> mesg <> "'")) con {-| Given a Hasql Connection and a channel sends a listen command to the database.@@ -103,7 +103,7 @@ listen con channel = void $ withLibPQConnection con execListen where- execListen pqCon = void $ PQ.exec pqCon $ "LISTEN " <> fromPgIdentifier channel+ execListen pqCon = void $ PQ.exec pqCon $ T.encodeUtf8 $ "LISTEN " <> fromPgIdentifier channel -- | Given a Hasql Connection and a channel sends a unlisten command to the database unlisten :: Connection -- ^ Connection currently registerd by a previous 'listen' call@@ -112,7 +112,7 @@ unlisten con channel = void $ withLibPQConnection con execListen where- execListen pqCon = void $ PQ.exec pqCon $ "UNLISTEN " <> fromPgIdentifier channel+ execListen pqCon = void $ PQ.exec pqCon $ T.encodeUtf8 $ "UNLISTEN " <> fromPgIdentifier channel {-|
test/Hasql/NotificationsSpec.hs view
@@ -22,7 +22,7 @@ describe "send and receive notification" $ describe "when I send a notification to channel my handler is listening to" $ it "should call our notification handler" $ do- dbOrError <- acquire "postgres://localhost/hasql_notifications_test"+ dbOrError <- acquire "postgres://postgres:roottoor@localhost/hasql_notifications_test" case dbOrError of Right db -> do let channelToListen = toPgIdentifier "test-channel"