Skip to content
Snippets Groups Projects
Commit 9ebfd210 authored by Ramakrishnan Muthukrishnan's avatar Ramakrishnan Muthukrishnan
Browse files

isVoucherUnpaid: fix an incorrect sql statement

Vouchers table contain all paid vouchers, so to find if a given
voucher is unpaid, all we need to do is check membership in the
`vouchers' table.
parent 017da3d0
No related branches found
No related tags found
1 merge request!26Initial implementation of Persistence using sqlite
......@@ -134,7 +134,7 @@ instance FromRow Fingerprint where
-- | Checks if the given `voucher` is unpaid.
isVoucherUnpaid :: Sqlite.Connection -> Voucher -> IO Bool
isVoucherUnpaid dbConn voucher =
null <$> (Sqlite.query dbConn "SELECT DISTINCT name FROM vouchers INNER JOIN redeemed WHERE vouchers.id != redeemed.voucher_id AND vouchers.name = ?" (Sqlite.Only voucher) :: IO [Voucher])
null <$> (Sqlite.query dbConn "SELECT 1 FROM vouchers WHERE vouchers.name = ? LIMIT 1" (Sqlite.Only voucher) :: IO [Voucher])
getVoucherFingerprint :: Sqlite.Connection -> Voucher -> IO [Fingerprint]
getVoucherFingerprint dbConn voucher =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment