-- | Diffirent invalid queries in batches.
testInvalidBatch :: IO ()
testInvalidBatch = do
    let rightQuery = makeQuery1 "5"
        q1 = Query "SEL $1" [(Oid 23, Just $ PE.bytea "5")] 
            Text Text NeverCache
        q2 = Query "SELECT $1" [(Oid 23, Just $ PE.bytea  "a")] 
            Text Text NeverCache
        q4 = Query "SELECT $1" [] Text Text NeverCache

    assertInvalidBatch "Parse error" [q1]
    assertInvalidBatch "Invalid param" [ q2]
    assertInvalidBatch "Missed oid of param" [ q4]
    assertInvalidBatch "Parse error" [rightQuery, q1]
    assertInvalidBatch "Invalid param" [rightQuery, q2]
    assertInvalidBatch "Missed oid of param" [rightQuery, q4]
  where
    assertInvalidBatch desc qs = withConnection $ \c -> do
        sendBatchAndSync c qs
        checkInvalidResult c $ length qs

-- | Connection remains valid even after PostgreSQL returned error on the 
-- previous query.
testInvalidBatch :: IO ()
testInvalidBatch = do
    let rightQuery = makeQuery1 "5"
        q1 = Query "SEL $1" [(Oid 23, Just $ PE.bytea "5")] 
            Text Text NeverCache
        q2 = Query "SELECT $1" [(Oid 23, Just $ PE.bytea  "a")] 
            Text Text NeverCache
        q4 = Query "SELECT $1" [] Text Text NeverCache

    assertInvalidBatch "Parse error" [q1]
    assertInvalidBatch "Invalid param" [ q2]
    assertInvalidBatch "Missed oid of param" [ q4]
    assertInvalidBatch "Parse error" [rightQuery, q1]
    assertInvalidBatch "Invalid param" [rightQuery, q2]
    assertInvalidBatch "Missed oid of param" [rightQuery, q4]
  where
    assertInvalidBatch desc qs = withConnection $ \c -> do
        sendBatchAndSync c qs
        checkInvalidResult c $ length qs

-- | Connection remains valid even after PostgreSQL returned error on the 
-- previous query.
testInvalidBatch = do
    let rightQuery = makeQuery1 "5"
        q1 = Query "SEL $1" [(Oid 23, Just $ PE.bytea "5")] 
            Text Text NeverCache
        q2 = Query "SELECT $1" [(Oid 23, Just $ PE.bytea  "a")] 
            Text Text NeverCache
        q4 = Query "SELECT $1" [] Text Text NeverCache

    assertInvalidBatch "Parse error" [q1]
    assertInvalidBatch "Invalid param" [ q2]
    assertInvalidBatch "Missed oid of param" [ q4]
    assertInvalidBatch "Parse error" [rightQuery, q1]
    assertInvalidBatch "Invalid param" [rightQuery, q2]
    assertInvalidBatch "Missed oid of param" [rightQuery, q4]
  where
    assertInvalidBatch desc qs = withConnection $ \c -> do
        sendBatchAndSync c qs
        checkInvalidResult c $ length qs

-- | Connection remains valid even after PostgreSQL returned error on the 
-- previous query.