Skip to content

Commit

Permalink
fix: 119, wrong order by
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed Oct 1, 2024
1 parent c51b9db commit 5879773
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions state/storage/pgstorage/sequenced_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (p *PostgresStorage) AddSequencedBatches(ctx context.Context, sequence *Seq
func (p *PostgresStorage) GetSequenceByBatchNumber(ctx context.Context, batchNumber uint64, dbTx dbTxType) (*SequencedBatches, error) {
const sql = `SELECT from_batch_num, to_batch_num,fork_id, timestamp,block_num, l1_info_root,received_at,source FROM sync.sequenced_batches
WHERE $1 >= from_batch_num AND $1 <= to_batch_num
ORDER BY block_num DESC LIMIT 1;`
ORDER BY from_batch_num DESC LIMIT 1;`
sequences, err := p.querySequences(ctx, fmt.Sprintf("GetSequenceByBatchNumber %d", batchNumber), sql, getPgTx(dbTx), batchNumber)
if err != nil {
return nil, err
Expand Down Expand Up @@ -57,7 +57,7 @@ func (p *PostgresStorage) GetLatestSequence(ctx context.Context, dbTx dbTxType)
func (p *PostgresStorage) GetSequencesGreatestOrEqualBatchNumber(ctx context.Context, batchNumber uint64, dbTx dbTxType) (*SequencedBatchesSlice, error) {
const sql = `SELECT from_batch_num, to_batch_num,fork_id, timestamp,block_num, l1_info_root,received_at,source FROM sync.sequenced_batches
WHERE from_batch_num >= $1 OR to_batch_num >= $1
ORDER BY block_num;`
ORDER BY from_batch_num;`
seq, err := p.querySequences(ctx, fmt.Sprintf("GetSequencesGreatestOrEqualBatchNumber %d", batchNumber), sql, getPgTx(dbTx), batchNumber)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions state/storage/sqlstorage/sequenced_batches.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (p *SqlStorage) GetSequenceByBatchNumber(ctx context.Context, batchNumber u
sql := sqlSelectSequencedBatches +
"FROM " + p.BuildTableName(sequencedBatchesTable) + " " +
"WHERE $1 >= from_batch_num AND $1 <= to_batch_num " +
"ORDER BY block_num DESC LIMIT 1;"
"ORDER BY from_batch_num DESC LIMIT 1;"
sequences, err := p.querySequences(ctx, fmt.Sprintf("GetSequenceByBatchNumber %d", batchNumber), sql, getSqlTx(dbTx), batchNumber)
if err != nil {
return nil, err
Expand All @@ -48,7 +48,7 @@ func (p *SqlStorage) GetSequenceByBatchNumber(ctx context.Context, batchNumber u
func (p *SqlStorage) GetLatestSequence(ctx context.Context, dbTx dbTxType) (*SequencedBatches, error) {
sql := sqlSelectSequencedBatches +
"FROM " + p.BuildTableName(sequencedBatchesTable) + " " +
"ORDER BY block_num DESC LIMIT 1;"
"ORDER BY from_batch_num DESC LIMIT 1;"
sequences, err := p.querySequences(ctx, "GetLatestSequence", sql, getSqlTx(dbTx))
if err != nil {
return nil, err
Expand All @@ -66,7 +66,7 @@ func (p *SqlStorage) GetSequencesGreatestOrEqualBatchNumber(ctx context.Context,
sql := sqlSelectSequencedBatches +
"FROM " + p.BuildTableName(sequencedBatchesTable) + " " +
"WHERE from_batch_num >= $1 OR to_batch_num >= $1 " +
"ORDER BY block_num;"
"ORDER BY from_batch_num;"
seq, err := p.querySequences(ctx, fmt.Sprintf("GetSequencesGreatestOrEqualBatchNumber %d", batchNumber), sql, getSqlTx(dbTx), batchNumber)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5879773

Please sign in to comment.