Skip to content

Commit 2072ede

Browse files
Tests connection remains valid after PostgresError
1 parent 2205b17 commit 2072ede

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/Driver.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ testDriver = testGroup "Driver"
3434
, testCase "Empty query" testEmptyQuery
3535
, testCase "Query without result" testQueryWithoutResult
3636
, testCase "Invalid queries" testInvalidBatch
37+
, testCase "Valid after postgres error" testValidAfterError
3738
, testCase "Describe statement" testDescribeStatement
3839
, testCase "Describe statement with no data" testDescribeStatementNoData
3940
, testCase "Describe empty statement" testDescribeStatementEmpty
@@ -155,6 +156,22 @@ testInvalidBatch = do
155156
sendBatchAndSync c qs
156157
checkInvalidResult c $ length qs
157158

159+
-- | Connection remains valid even after PostgreSQL returned error on the
160+
-- previous query.
161+
testValidAfterError :: IO ()
162+
testValidAfterError = withConnection $ \c -> do
163+
let a = "5"
164+
rightQuery = makeQuery1 a
165+
invalidQuery = Query "SELECT $1" (V.fromList []) Text Text NeverCache
166+
sendBatchAndSync c [invalidQuery]
167+
checkInvalidResult c 1
168+
waitReadyForQuery c
169+
170+
sendBatchAndSync c [rightQuery]
171+
r <- readNextData c
172+
waitReadyForQuery c
173+
a @=? fromMessage r
174+
158175
-- | Describes usual statement.
159176
testDescribeStatement :: IO ()
160177
testDescribeStatement = withConnectionCommon $ \c -> do

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy