mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix(eventstore): precise decimal (#8527)
# Which Problems Are Solved Float64 which was used for the event.Position field is [not precise in go and gets rounded](https://github.com/golang/go/issues/47300). This can lead to unprecies position tracking of events and therefore projections especially on cockcoachdb as the position used there is a big number. example of a unprecies position: exact: 1725257931223002628 float64: 1725257931223002624.000000 # How the Problems Are Solved The float64 was replaced by [github.com/jackc/pgx-shopspring-decimal](https://github.com/jackc/pgx-shopspring-decimal). # Additional Changes Correct behaviour of makefile for load tests. Rename `latestSequence`-queries to `latestPosition`
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/v2/database"
|
||||
)
|
||||
|
||||
@@ -74,13 +76,13 @@ func TestPaginationOpt(t *testing.T) {
|
||||
name: "global position greater",
|
||||
args: args{
|
||||
opts: []paginationOpt{
|
||||
GlobalPositionGreater(&GlobalPosition{Position: 10}),
|
||||
GlobalPositionGreater(&GlobalPosition{Position: decimal.NewFromInt(10)}),
|
||||
},
|
||||
},
|
||||
want: &Pagination{
|
||||
position: &PositionCondition{
|
||||
min: &GlobalPosition{
|
||||
Position: 10,
|
||||
Position: decimal.NewFromInt(10),
|
||||
InPositionOrder: 0,
|
||||
},
|
||||
},
|
||||
@@ -90,13 +92,13 @@ func TestPaginationOpt(t *testing.T) {
|
||||
name: "position greater",
|
||||
args: args{
|
||||
opts: []paginationOpt{
|
||||
PositionGreater(10, 0),
|
||||
PositionGreater(decimal.NewFromInt(10), 0),
|
||||
},
|
||||
},
|
||||
want: &Pagination{
|
||||
position: &PositionCondition{
|
||||
min: &GlobalPosition{
|
||||
Position: 10,
|
||||
Position: decimal.NewFromInt(10),
|
||||
InPositionOrder: 0,
|
||||
},
|
||||
},
|
||||
@@ -107,13 +109,13 @@ func TestPaginationOpt(t *testing.T) {
|
||||
name: "position less",
|
||||
args: args{
|
||||
opts: []paginationOpt{
|
||||
PositionLess(10, 12),
|
||||
PositionLess(decimal.NewFromInt(10), 12),
|
||||
},
|
||||
},
|
||||
want: &Pagination{
|
||||
position: &PositionCondition{
|
||||
max: &GlobalPosition{
|
||||
Position: 10,
|
||||
Position: decimal.NewFromInt(10),
|
||||
InPositionOrder: 12,
|
||||
},
|
||||
},
|
||||
@@ -123,13 +125,13 @@ func TestPaginationOpt(t *testing.T) {
|
||||
name: "global position less",
|
||||
args: args{
|
||||
opts: []paginationOpt{
|
||||
GlobalPositionLess(&GlobalPosition{Position: 12, InPositionOrder: 24}),
|
||||
GlobalPositionLess(&GlobalPosition{Position: decimal.NewFromInt(12), InPositionOrder: 24}),
|
||||
},
|
||||
},
|
||||
want: &Pagination{
|
||||
position: &PositionCondition{
|
||||
max: &GlobalPosition{
|
||||
Position: 12,
|
||||
Position: decimal.NewFromInt(12),
|
||||
InPositionOrder: 24,
|
||||
},
|
||||
},
|
||||
@@ -140,19 +142,19 @@ func TestPaginationOpt(t *testing.T) {
|
||||
args: args{
|
||||
opts: []paginationOpt{
|
||||
PositionBetween(
|
||||
&GlobalPosition{10, 12},
|
||||
&GlobalPosition{20, 0},
|
||||
&GlobalPosition{decimal.NewFromInt(10), 12},
|
||||
&GlobalPosition{decimal.NewFromInt(20), 0},
|
||||
),
|
||||
},
|
||||
},
|
||||
want: &Pagination{
|
||||
position: &PositionCondition{
|
||||
min: &GlobalPosition{
|
||||
Position: 10,
|
||||
Position: decimal.NewFromInt(10),
|
||||
InPositionOrder: 12,
|
||||
},
|
||||
max: &GlobalPosition{
|
||||
Position: 20,
|
||||
Position: decimal.NewFromInt(20),
|
||||
InPositionOrder: 0,
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user