{- |
  Constructs a `FakeLibPQResult`. The column names given as associated with
  the values for each row by their position in list. Any missing values (e.g.
  because a row is shorter than the heeader list) are treated as a SQL Null
  value.
-}
mkFakeLibPQResult ::
  -- | The column names for the result set
  [BS.ByteString] ->
  -- | The row data for the result set
  [[SqlValue]] ->
  FakeLibPQResult
mkFakeLibPQResult columnList valuesList =
  let indexedRows = do
        (rowNumber, row) <- zip [Row 0 ..] valuesList

        let indexedColumns = zip [Column 0 ..] row

        pure (rowNumber, Map.fromList indexedColumns)
   in FakeLibPQResult
        { fakeLibPQColumns = Map.fromList (zip [Column 0 ..] columnList)
        , fakeLibPQRows = Map.fromList indexedRows
        }
mkFakeLibPQResult ::
  -- | The column names for the result set
  [BS.ByteString] ->
  -- | The row data for the result set
  [[SqlValue]] ->
  FakeLibPQResult
mkFakeLibPQResult columnList valuesList =
  let indexedRows = do
        (rowNumber, row) <- zip [Row 0 ..] valuesList

        let indexedColumns = zip [Column 0 ..] row

        pure (rowNumber, Map.fromList indexedColumns)
   in FakeLibPQResult
        { fakeLibPQColumns = Map.fromList (zip [Column 0 ..] columnList)
        , fakeLibPQRows = Map.fromList indexedRows
        }
mkFakeLibPQResult columnList valuesList =
  let indexedRows = do
        (rowNumber, row) <- zip [Row 0 ..] valuesList

        let indexedColumns = zip [Column 0 ..] row

        pure (rowNumber, Map.fromList indexedColumns)
   in FakeLibPQResult
        { fakeLibPQColumns = Map.fromList (zip [Column 0 ..] columnList)
        , fakeLibPQRows = Map.fromList indexedRows
        }