Skip to content

Commit 57f9329

Browse files
authored
Merge pull request #2021 from IntersectMBO/hotfix/genesis-rollback-fix
hotfix/genesis rollback fix + no partials fix
2 parents 4ddefc1 + 0a41025 commit 57f9329

File tree

2 files changed

+7
-2
lines changed
  • cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway
  • cardano-db/src/Cardano/Db/Statement

2 files changed

+7
-2
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Rollback.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE NumericUnderscores #-}
3+
4+
#if __GLASGOW_HASKELL__ >= 908
25
{-# OPTIONS_GHC -Wno-x-partial #-}
6+
#endif
37

48
module Test.Cardano.Db.Mock.Unit.Conway.Rollback (
59
simpleRollback,

cardano-db/src/Cardano/Db/Statement/Base.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ queryBlockNoAndEpochStmt =
192192
-- (where DrepDistr will be inserted). Using the previous block's epoch ensures
193193
-- DrepDistr for the current epoch gets deleted, preventing duplicates
194194
-- when replaying through the epoch boundary.
195+
-- For genesis (block 0), there's no previous block, so use the current epoch.
195196
sql =
196197
TextEnc.encodeUtf8 $
197198
Text.concat
198-
[ "SELECT curr.id, prev.epoch_no"
199+
[ "SELECT curr.id, COALESCE(prev.epoch_no, curr.epoch_no)"
199200
, " FROM " <> tableName (Proxy @a) <> " curr"
200-
, " JOIN " <> tableName (Proxy @a) <> " prev ON prev.block_no = $1 - 1"
201+
, " LEFT JOIN " <> tableName (Proxy @a) <> " prev ON prev.block_no = $1 - 1"
201202
, " WHERE curr.block_no = $1"
202203
]
203204

0 commit comments

Comments
 (0)