Skip to content

Commit

Permalink
fix(server): integer/number related min/max props should be nullable (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yk-eukarya authored Oct 28, 2024
1 parent 411360d commit c23dfad
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions server/internal/adapter/gql/gqlmodel/convert_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/reearth/reearth-cms/server/pkg/value"
"github.com/reearth/reearthx/i18n"
"github.com/reearth/reearthx/rerror"
"github.com/reearth/reearthx/util"
"github.com/samber/lo"
)

Expand Down Expand Up @@ -270,8 +269,8 @@ func ToSchemaFieldTypeProperty(tp *schema.TypeProperty, dv *value.Multiple, mult
}
res = &SchemaFieldNumber{
DefaultValue: v,
Min: util.ToPtrIfNotEmpty(float64(lo.FromPtr(f.Min()))),
Max: util.ToPtrIfNotEmpty(float64(lo.FromPtr(f.Max()))),
Min: f.Min(),
Max: f.Max(),
}
},
Integer: func(f *schema.FieldInteger) {
Expand All @@ -285,8 +284,8 @@ func ToSchemaFieldTypeProperty(tp *schema.TypeProperty, dv *value.Multiple, mult
}
res = &SchemaFieldInteger{
DefaultValue: v,
Min: util.ToPtrIfNotEmpty(int(lo.FromPtr(f.Min()))),
Max: util.ToPtrIfNotEmpty(int(lo.FromPtr(f.Max()))),
Min: intPtr(f.Min()),
Max: intPtr(f.Max()),
}
},
Reference: func(f *schema.FieldReference) {
Expand Down Expand Up @@ -673,3 +672,10 @@ func unpackArray(s any) []any {
}
return r
}

func intPtr(v *int64) *int {
if v == nil {
return nil
}
return lo.ToPtr((int)(*v))
}

0 comments on commit c23dfad

Please sign in to comment.