Skip to content

Commit

Permalink
Merge #2053
Browse files Browse the repository at this point in the history
2053: Use ? placeholder syntax in `listRetiredPools`. r=jonathanknowles a=jonathanknowles

# Issue Number

#2016 

# Overview

This PR adjusts `listRetiredPools` to use the `?` placeholder syntax when constructing a raw SQL query.

Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
  • Loading branch information
iohk-bors[bot] and jonathanknowles authored Aug 20, 2020
2 parents 86c1eb8 + b4d4160 commit c84ac72
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ import Database.Persist.Sql
, repsert
, selectFirst
, selectList
, toPersistValue
, (<.)
, (==.)
, (>.)
Expand All @@ -129,7 +130,6 @@ import Cardano.Pool.DB.Sqlite.TH

import qualified Data.Map.Strict as Map
import qualified Data.Text as T
import qualified Data.Text.Class as T
import qualified Database.Sqlite as Sqlite

-- | Return the preferred @FilePath@ for the stake pool .sqlite file, given a
Expand Down Expand Up @@ -364,17 +364,16 @@ newDBLayer trace fp timeInterpreter = do

, listRetiredPools = \epochNo -> do
let query = T.unwords
[ "SELECT * FROM "
, databaseViewName activePoolRetirements
, "WHERE retirement_epoch <="
, T.toText epochNo
, ";"
[ "SELECT *"
, "FROM active_pool_retirements"
, "WHERE retirement_epoch <= ?;"
]
let parameters = [ toPersistValue epochNo ]
let safeCast (Single poolId, Single retirementEpoch) =
PoolRetirementCertificate
<$> fromPersistValue poolId
<*> fromPersistValue retirementEpoch
rights . fmap safeCast <$> rawSql query []
rights . fmap safeCast <$> rawSql query parameters

, rollbackTo = \point -> do
-- TODO(ADP-356): What if the conversion blocks or fails?
Expand Down

0 comments on commit c84ac72

Please sign in to comment.