From 163bba2882da8d9099de32f3afc65838d9718355 Mon Sep 17 00:00:00 2001 From: Tolga Ozen Date: Tue, 4 Jul 2023 15:20:52 +0300 Subject: [PATCH] fix: max(xid8) to limit version --- internal/storage/postgres/relationshipReader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/storage/postgres/relationshipReader.go b/internal/storage/postgres/relationshipReader.go index 646444673..847061496 100644 --- a/internal/storage/postgres/relationshipReader.go +++ b/internal/storage/postgres/relationshipReader.go @@ -300,7 +300,7 @@ func (r *RelationshipReader) HeadSnapshot(ctx context.Context, tenantID string) var xid types.XID8 // Build the query to find the highest transaction ID associated with the tenant. - builder := r.database.Builder.Select("MAX(id)").From(TransactionsTable).Where(squirrel.Eq{"tenant_id": tenantID}) + builder := r.database.Builder.Select("id").From(TransactionsTable).Where(squirrel.Eq{"tenant_id": tenantID}).OrderBy("id DESC").Limit(1) query, args, err := builder.ToSql() if err != nil { span.RecordError(err)