From 905dfcd13079f2210113e57a69aa4746801fd268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Sala=C3=BCn?= Date: Mon, 5 Feb 2024 16:30:13 +0100 Subject: [PATCH] fix: postgres timestamp casting should include timezone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Salaün --- pkg/storage/sqlstorage/transactions.go | 2 +- pkg/storage/sqlstorage/transactions_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/storage/sqlstorage/transactions.go b/pkg/storage/sqlstorage/transactions.go index 4f12f85a3..e483bc5c9 100644 --- a/pkg/storage/sqlstorage/transactions.go +++ b/pkg/storage/sqlstorage/transactions.go @@ -461,7 +461,7 @@ func (s *Store) insertTransactions(ctx context.Context, txs ...core.ExpandedTran pre_commit_volumes, post_commit_volumes) (SELECT * FROM unnest( $1::int[], - $2::timestamp[], + $2::timestamptz[], $3::varchar[], $4::jsonb[], $5::jsonb[], diff --git a/pkg/storage/sqlstorage/transactions_test.go b/pkg/storage/sqlstorage/transactions_test.go index 3fa52f019..7433bb175 100644 --- a/pkg/storage/sqlstorage/transactions_test.go +++ b/pkg/storage/sqlstorage/transactions_test.go @@ -353,6 +353,9 @@ func testTransactions(t *testing.T, store *sqlstorage.Store) { // Should get only the first transaction. require.Equal(t, 1, cursor.PageSize) + // Transaction timestamp fetched should be equal to the timestamp of the committed transaction. + require.Equal(t, cursor.Data[0].Timestamp, tx3.Timestamp.Format(time.RFC3339)) + cursor, err = store.GetTransactions(context.Background(), ledger.TransactionsQuery{ AfterTxID: cursor.Data[0].ID, PageSize: 1,